Skip to content
Myr

Fixed a translation error caused by looping over empty recursive loops.

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 2bc1ef7 · Browse files · 3 files+15 added−5 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+15 added−5 removed

  • tests:+7 added−0 removed
  • other:+8 added−5 removed

3 files+15 added−5 removed

modified:jinja2/compiler.py+3 added-2 removed
654 unmodified lines
655 def position(self, node):656 """Return a human readable position for the node."""657 rv = 'line %d' % node.lineno658 if self.name is not None:659 rv += ' in' + repr(self.name)659 rv += ' in ' + repr(self.name)660 return rv661662 # -- Statement Visitors663
347 unmodified lines
1011 self.blockvisit(node.else_, loop_frame)1012 self.outdent()10131014 # reset the aliases if there are any.1015 if not node.recursive:1015 self.pop_scope(aliases, loop_frame)1016 self.pop_scope(aliases, loop_frame)10171018 # if the node was recursive we have to return the buffer contents1019 # and start the iteration code1020 if node.recursive:
424 unmodified lines
modified:tests/test_forloop.py+7 added
151 unmodified lines
152 assert t.render(seq='ab') == 'TrueFalse'153 t = env.from_string('{% for x in seq %}{% for y in seq %}'154 '{{ loop.first }}{% endfor %}{% endfor %}')155 assert t.render(seq='ab') == 'TrueFalseTrueFalse'156157158def test_recursive_empty_loop_iter(env):159 t = env.from_string('''160 {%- for item in foo recursive -%}{%- endfor -%}161 ''')162 assert t.render(dict(foo=[])) == ''
modified:CHANGES+5 added-3 removed
1Jinja2 Changelog2================34Version 2.25-----------6(codename to be selected, release date yet unknown)4Version 2.1.15-------------6(Bugfix release)78- Fixed a translation error caused by looping over empty recursive loops.910Version 2.111-----------12(codename Yasuzō, released on November 23rd 2008)13
77 unmodified lines