Fix issue when extensions are not installed with jinja2

This commit is contained in:
Thomas S Hatch 2013-01-11 12:58:44 -07:00
parent d11f07b4b4
commit 01078aed4e

View File

@ -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: