Skip to content

Commit

Permalink
Try allowing include of templates relative to parent template
Browse files Browse the repository at this point in the history
  • Loading branch information
indy-independence committed May 7, 2021
1 parent 76a1331 commit 6580403
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/cnaas_nms/confpush/nornir_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,16 @@ class NornirJobResult(JobResult):
change_score: Optional[float] = None


cnaas_jinja_env = JinjaEnvironment(
class RelativeJinjaEnvironment(JinjaEnvironment):
"""Enable relative template paths"""
def join_path(self, template, parent):
return os.path.join(os.path.dirname(parent), template)


cnaas_jinja_env = RelativeJinjaEnvironment(
trim_blocks=True,
lstrip_blocks=True,
keep_trailing_newline=True,
cache_size=0
keep_trailing_newline=True
)


Expand Down

0 comments on commit 6580403

Please sign in to comment.