mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 08:58:59 +00:00
Fix issue when extensions are not installed with jinja2
This commit is contained in:
parent
d11f07b4b4
commit
01078aed4e
@ -14,6 +14,7 @@ import traceback
|
|||||||
|
|
||||||
# Import third party libs
|
# Import third party libs
|
||||||
import jinja2
|
import jinja2
|
||||||
|
import jinja2.ext
|
||||||
|
|
||||||
# Import salt libs
|
# Import salt libs
|
||||||
import salt.utils
|
import salt.utils
|
||||||
@ -85,7 +86,9 @@ def render_jinja_tmpl(tmplstr, context, tmplpath=None):
|
|||||||
loader = jinja2.FileSystemLoader(context, os.path.dirname(tmplpath))
|
loader = jinja2.FileSystemLoader(context, os.path.dirname(tmplpath))
|
||||||
else:
|
else:
|
||||||
loader = JinjaSaltCacheLoader(opts, context['env'])
|
loader = JinjaSaltCacheLoader(opts, context['env'])
|
||||||
env_args = {'extensions': ['jinja2.ext.with_'], 'loader': loader}
|
env_args = {'extensions': [], 'loader': loader}
|
||||||
|
if hasattr(jinja2.ext, 'with_'):
|
||||||
|
env_args['extensions'].append('jinja2.ext.with_')
|
||||||
if opts.get('allow_undefined', False):
|
if opts.get('allow_undefined', False):
|
||||||
jinja_env = jinja2.Environment(**env_args)
|
jinja_env = jinja2.Environment(**env_args)
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user