]> git.ipfire.org Git - thirdparty/jinja.git/commitdiff
BUGFIX #930 - Template parse if with when referencing with dictionary subproperty 1002/head
authoreplata31 <eplata31@outlook.com>
Mon, 13 May 2019 20:46:41 +0000 (15:46 -0500)
committereplata31 <eplata31@outlook.com>
Mon, 13 May 2019 20:46:41 +0000 (15:46 -0500)
jinja2/parser.py
tests/test_regression.py

index d712fd3ea1ce52b41b0d98264034bb6f4dc0ddb7..c91683e8b8a151066574e20f91347905c0c84cac 100644 (file)
@@ -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,
index 876b41c82c7ff8578f3b95da7d6f5dcea728f42d..d540d2dd1c73ff920bc95b7c51f9366ae8c1a434 100644 (file)
@@ -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',