Skip to content

Commit

Permalink
Merge pull request #3417 from dmbaturin/T3664-template-path-var
Browse files Browse the repository at this point in the history
vyos.template: T3664: add a module-level variable for template directory
  • Loading branch information
jestabro authored May 6, 2024
2 parents 199ee2d + 55fb42b commit e54cffa
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion python/vyos/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@
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 = {}
Expand All @@ -33,7 +41,7 @@
@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(
Expand Down

0 comments on commit e54cffa

Please sign in to comment.