Skip to content
Myr

Merge pull request #1002 from eplata31/bugfix-template-parse-if-with-dict-subproperty

Before adoption: this commit came in with the history the project adopted, so no landing records it.

BUGFIX #930 - Template parse if with when referencing with dictionary…

authored by Kevin Brown · committed by GitHub · parents 321b499, 9b38bb4 · Browse files · 2 files+7 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+7 added−1 removed

  • tests:+4 added−0 removed
  • other:+3 added−1 removed

2 files+7 added−1 removed

modified:jinja2/parser.py+3 added-1 removed
839 unmodified lines
840 self.stream.current.test_any('name:else', 'name:or',841 'name:and')):842 if self.stream.current.test('name:is'):843 self.fail('You cannot chain multiple tests with is')844 args = [self.parse_primary()]844 arg_node = self.parse_primary()845 arg_node = self.parse_postfix(arg_node)846 args = [arg_node]847 else:848 args = []849 node = nodes.Test(node, name, args, kwargs, dyn_args,850 dyn_kwargs, lineno=token.lineno)
57 unmodified lines
modified:tests/test_regression.py+4 added
481 unmodified lines
482 def test_empty_if(self, env):483 t = env.from_string('{% if foo %}{% else %}42{% endif %}')484 assert t.render(foo=False) == '42'485486 def test_subproperty_if(self, env):487 t = env.from_string('{% if object1.subproperty1 is eq object2.subproperty2 %}42{% endif %}')488 assert t.render(object1={'subproperty1': 'value'}, object2={'subproperty2': 'value'}) == '42'489490 def test_set_and_include(self):491 env = Environment(loader=DictLoader({492 'inc': 'bar',493 'main': '{% set foo = "foo" %}{{ foo }}{% include "inc" %}'
52 unmodified lines