Fix for bug in Conditional for older jinja2 versions

Fixes #20309

(cherry picked from commit af96cba7e1)
pull/21095/head
James Cammarata 8 years ago
parent 2c832c736f
commit 59407cf2cb

@ -22,6 +22,7 @@ __metaclass__ = type
import ast import ast
import re import re
from jinja2.compiler import generate
from jinja2.exceptions import UndefinedError from jinja2.exceptions import UndefinedError
from ansible.compat.six import text_type from ansible.compat.six import text_type
@ -123,7 +124,7 @@ class Conditional:
presented = "{%% if %s %%} True {%% else %%} False {%% endif %%}" % conditional presented = "{%% if %s %%} True {%% else %%} False {%% endif %%}" % conditional
res = e._parse(presented, None, None) res = e._parse(presented, None, None)
res = e._generate(res, None, None, defer_init=True) res = generate(res, e, None, None)
parsed = ast.parse(res, mode='exec') parsed = ast.parse(res, mode='exec')
class CleansingNodeVisitor(ast.NodeVisitor): class CleansingNodeVisitor(ast.NodeVisitor):

Loading…
Cancel
Save