Merge pull request #3645 from stoned/stringify-conditional-2

stringify conditional before handing it to Jinja2 for evaluation.
This commit is contained in:
Michael DeHaan
2013-08-01 17:08:34 -07:00
2 changed files with 95 additions and 1 deletions

View File

@@ -164,7 +164,7 @@ def check_conditional(conditional, basedir, inject, fail_on_undefined=False):
conditional = inject[conditional]
conditional = template.template(basedir, conditional, inject, fail_on_undefined=fail_on_undefined)
# a Jinja2 evaluation that results in something Python can eval!
presented = "{% if " + conditional + " %} True {% else %} False {% endif %}"
presented = "{%% if %s %%} True {%% else %%} False {%% endif %%}" % conditional
conditional = template.template(basedir, presented, inject)
val = conditional.lstrip().rstrip()
if val == "True":