summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Estabrook <jestabro@vyos.io>2024-05-06 14:54:24 -0500
committerGitHub <noreply@github.com>2024-05-06 14:54:24 -0500
commite54cffa9615acb8dd99b9b90621a004f15941321 (patch)
tree66a63b3c8c4fd64f2607e2b3a0369756f371e358
parent199ee2df43e04ca1d55ea7dfa3b5901ea75c0f78 (diff)
parent55fb42b13321359537316b02f015dc29aa142b71 (diff)
downloadvyos-1x-e54cffa9615acb8dd99b9b90621a004f15941321.tar.gz
vyos-1x-e54cffa9615acb8dd99b9b90621a004f15941321.zip
Merge pull request #3417 from dmbaturin/T3664-template-path-var
vyos.template: T3664: add a module-level variable for template directory
-rw-r--r--python/vyos/template.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/python/vyos/template.py b/python/vyos/template.py
index ffccae9a1..cdcbdc6c3 100644
--- a/python/vyos/template.py
+++ b/python/vyos/template.py
@@ -25,6 +25,14 @@ from vyos.utils.file import makedir
from vyos.utils.permission import chmod
from vyos.utils.permission import chown
+# We use a mutable global variable for the default template directory
+# to make it possible to call scripts from this repository
+# outside of live VyOS systems.
+# If something (like the image build scripts)
+# want to call a script, they can modify the default location
+# to the repository path.
+DEFAULT_TEMPLATE_DIR = directories["templates"]
+
# Holds template filters registered via register_filter()
_FILTERS = {}
_TESTS = {}
@@ -33,7 +41,7 @@ _TESTS = {}
@functools.lru_cache(maxsize=2)
def _get_environment(location=None):
if location is None:
- loc_loader=FileSystemLoader(directories["templates"])
+ loc_loader=FileSystemLoader(DEFAULT_TEMPLATE_DIR)
else:
loc_loader=FileSystemLoader(location)
env = Environment(