Fixup jinja2 loader configuration
This commit is contained in:
parent
eba40a46dc
commit
85328c6aa1
4
.gitignore
vendored
4
.gitignore
vendored
@ -55,4 +55,6 @@ ChangeLog
|
|||||||
.*sw?
|
.*sw?
|
||||||
|
|
||||||
# Files created by releasenotes build
|
# Files created by releasenotes build
|
||||||
releasenotes/build
|
releasenotes/build
|
||||||
|
|
||||||
|
.settings
|
||||||
|
@ -26,17 +26,18 @@ class SnapFileRenderer():
|
|||||||
'''Helper class for rendering snap templates for runtime use'''
|
'''Helper class for rendering snap templates for runtime use'''
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self._loaders = [
|
self._tmpl_env = Environment(
|
||||||
FileSystemLoader(os.path.join(os.environ.get('SNAP'),
|
loader=FileSystemLoader(os.path.join(os.environ.get('SNAP'),
|
||||||
'templates'))
|
'templates')),
|
||||||
]
|
trim_blocks=True
|
||||||
self._tmpl_env = Environment(loader=self._loaders)
|
)
|
||||||
|
|
||||||
def render(self, template_name, env):
|
def render(self, template_name, env):
|
||||||
'''Render j2 template using SNAP environment context
|
'''Render j2 template using SNAP environment context provided
|
||||||
|
|
||||||
@param template_name: name of the template to use for rendering
|
@param template_name: name of the template to use for rendering
|
||||||
@return: string of rendered context, ready to write back to a file
|
@param env: dict of variables to pass to the renderer
|
||||||
|
@return: string of rendered data, ready to write back to a file
|
||||||
'''
|
'''
|
||||||
try:
|
try:
|
||||||
template = self._tmpl_env.get_template(template_name)
|
template = self._tmpl_env.get_template(template_name)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user