Fixup jinja2 loader configuration

This commit is contained in:
James Page 2016-11-10 09:58:20 +00:00
parent eba40a46dc
commit 85328c6aa1
2 changed files with 11 additions and 8 deletions

4
.gitignore vendored
View File

@ -55,4 +55,6 @@ ChangeLog
.*sw?
# Files created by releasenotes build
releasenotes/build
releasenotes/build
.settings

View File

@ -26,17 +26,18 @@ class SnapFileRenderer():
'''Helper class for rendering snap templates for runtime use'''
def __init__(self):
self._loaders = [
FileSystemLoader(os.path.join(os.environ.get('SNAP'),
'templates'))
]
self._tmpl_env = Environment(loader=self._loaders)
self._tmpl_env = Environment(
loader=FileSystemLoader(os.path.join(os.environ.get('SNAP'),
'templates')),
trim_blocks=True
)
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
@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:
template = self._tmpl_env.get_template(template_name)