Further WIP on template cleanup.

pull/4581/head
Michael DeHaan 11 years ago
parent 35cb9dc22f
commit 1e85c7544b

@ -394,6 +394,7 @@ def template_from_file(basedir, path, vars):
environment.filters.update(_get_filters()) environment.filters.update(_get_filters())
environment.globals['lookup'] = my_lookup environment.globals['lookup'] = my_lookup
if fail_on_undefined: if fail_on_undefined:
print "DEBUG: fail on undefined is engaged"
environment.undefined = StrictUndefined environment.undefined = StrictUndefined
try: try:
@ -438,7 +439,7 @@ def template_from_file(basedir, path, vars):
) )
try: try:
res = template.render(vars) res = t.render(vars)
except jinja2.exceptions.UndefinedError, e: except jinja2.exceptions.UndefinedError, e:
raise errors.AnsibleUndefinedVariable("One or more undefined variables: %s" % str(e)) raise errors.AnsibleUndefinedVariable("One or more undefined variables: %s" % str(e))
@ -453,6 +454,9 @@ def template_from_string(basedir, data, vars, fail_on_undefined=False):
data = unicode(data, 'utf-8') data = unicode(data, 'utf-8')
environment = jinja2.Environment(trim_blocks=True, undefined=StrictUndefined, extensions=_get_extensions()) environment = jinja2.Environment(trim_blocks=True, undefined=StrictUndefined, extensions=_get_extensions())
environment.filters.update(_get_filters()) environment.filters.update(_get_filters())
if fail_on_undefined:
print "DEBUG: fail on undefined is engaged, 2"
environment.undefined = StrictUndefined
if '_original_file' in vars: if '_original_file' in vars:
basedir = os.path.dirname(vars['_original_file']) basedir = os.path.dirname(vars['_original_file'])

Loading…
Cancel
Save