From: eplata31 Date: Mon, 13 May 2019 20:46:41 +0000 (-0500) Subject: BUGFIX #930 - Template parse if with when referencing with dictionary subproperty X-Git-Tag: 2.11.0~86^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F1002%2Fhead;p=thirdparty%2Fjinja.git BUGFIX #930 - Template parse if with when referencing with dictionary subproperty --- diff --git a/jinja2/parser.py b/jinja2/parser.py index d712fd3e..c91683e8 100644 --- a/jinja2/parser.py +++ b/jinja2/parser.py @@ -841,7 +841,9 @@ class Parser(object): 'name:and')): if self.stream.current.test('name:is'): self.fail('You cannot chain multiple tests with is') - args = [self.parse_primary()] + arg_node = self.parse_primary() + arg_node = self.parse_postfix(arg_node) + args = [arg_node] else: args = [] node = nodes.Test(node, name, args, kwargs, dyn_args, diff --git a/tests/test_regression.py b/tests/test_regression.py index 876b41c8..d540d2dd 100644 --- a/tests/test_regression.py +++ b/tests/test_regression.py @@ -483,6 +483,10 @@ class TestBug(object): t = env.from_string('{% if foo %}{% else %}42{% endif %}') assert t.render(foo=False) == '42' + def test_subproperty_if(self, env): + t = env.from_string('{% if object1.subproperty1 is eq object2.subproperty2 %}42{% endif %}') + assert t.render(object1={'subproperty1': 'value'}, object2={'subproperty2': 'value'}) == '42' + def test_set_and_include(self): env = Environment(loader=DictLoader({ 'inc': 'bar',