Skip to content
Myr

allow scoped blocks to access loop vars

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

authored by Amy · committed by Amy · parent 94ccd02 · Browse files · 1 file+6 added−3 removed
This commit

State

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

Diff stats

1 file+6 added−3 removed

  • other:+6 added−3 removed

1 file+6 added−3 removed

modified:src/jinja2/compiler.py+6 added-3 removed
1006 unmodified lines
1007 else_frame = frame.inner()10081009 # try to figure out if we have an extended loop. An extended loop1010 # is necessary if the loop is in recursive mode if the special loop1011 # variable is accessed in the body.1012 extended_loop = node.recursive or "loop" in find_undeclared(1013 node.iter_child_nodes(only=("body",)), ("loop",)1011 # variable is accessed in the body if the body is a scoped block.1012 extended_loop = (1013 node.recursive1014 or "loop"1015 in find_undeclared(node.iter_child_nodes(only=("body",)), ("loop",))1016 or any(block.scoped for block in node.find_all(nodes.Block))1017 )10181019 loop_ref = None1020 if extended_loop:
747 unmodified lines