1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Further WIP on template cleanup.

This commit is contained in:
Michael DeHaan 2013-10-19 10:51:35 -04:00
parent 35cb9dc22f
commit 1e85c7544b

View file

@ -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'])