Skip to content
Myr

Fixed a bug in the parser that made ``{{ foo[1, 2] }}`` impossible.

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

--HG-- branch : trunk

authored by Armin Ronacher · committed by Armin Ronacher · parent b3b5802 · Browse files · 3 files+10 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

3 files+10 added−1 removed

  • tests:+8 added−0 removed
  • other:+2 added−1 removed

3 files+10 added−1 removed

modified:jinja2/parser.py+1 added-1 removed
600 unmodified lines
601 self.stream.expect('rbracket')602 if len(args) == 1:603 arg = args[0]604 else:605 arg = nodes.Tuple(args, self.lineno, self.filename)605 arg = nodes.Tuple(args, 'load', lineno=token.lineno)606 return nodes.Getitem(node, arg, 'load', lineno=token.lineno)607 self.fail('expected subscript expression', self.lineno)608609 def parse_subscribed(self):
173 unmodified lines
modified:tests/test_syntax.py+8 added
193 unmodified lines
194def test_notin(env):195 bar = xrange(100)196 tmpl = env.from_string('''{{ not 42 in bar }}''')197 assert tmpl.render(bar=bar) == unicode(not 42 in bar)198199200def test_implicit_subscribed_tuple(env):201 class Foo(object):202 def __getitem__(self, x):203 return x204 t = env.from_string('{{ foo[1, 2] }}')205 assert t.render(foo=Foo()) == u'(1, 2)'
modified:CHANGES+1 added
10 unmodified lines
11 as an alias to `foo not in bar` like in python. Previously the grammar12 required parentheses (`not (foo in bar)`) which was odd.13- Fixed a bug that caused syntax errors when defining macros or using the14 `{% call %}` tag inside loops.15- Fixed a bug in the parser that made ``{{ foo[1, 2] }}`` impossible.1617Version 2.1.118-------------19(Bugfix release)
84 unmodified lines