From: Armin Ronacher Date: Thu, 14 Jan 2010 00:20:46 +0000 (+0100) Subject: fixed a problem with having call blocks in outer scopes that X-Git-Tag: 2.3~42 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e0016f5c62437f29a569c1d4067f16af3085ced1;p=thirdparty%2Fjinja.git fixed a problem with having call blocks in outer scopes that have an argument that is also used as local variable in an inner frame [#360]. --HG-- branch : trunk --- diff --git a/CHANGES b/CHANGES index 18bbc3d9..8a155bed 100644 --- a/CHANGES +++ b/CHANGES @@ -11,6 +11,9 @@ Version 2.3 - include tags are now able to select between multiple templates and take the first that exists, if a list of templates is given. +- fixed a problem with having call blocks in outer scopes that + have an argument that is also used as local variable in an + inner frame [#360]. Version 2.2.1 ------------- diff --git a/jinja2/compiler.py b/jinja2/compiler.py index 36d829ab..bcb22876 100644 --- a/jinja2/compiler.py +++ b/jinja2/compiler.py @@ -327,7 +327,7 @@ class FrameIdentifierVisitor(NodeVisitor): self.visit(node.iter) def visit_CallBlock(self, node): - for child in node.iter_child_nodes(exclude=('body',)): + for child in node.iter_child_nodes(exclude=('body', 'args')): self.visit(child) def visit_FilterBlock(self, node): diff --git a/tests/test_old_bugs.py b/tests/test_old_bugs.py index 110b7375..e3a403bd 100644 --- a/tests/test_old_bugs.py +++ b/tests/test_old_bugs.py @@ -8,7 +8,7 @@ :copyright: (c) 2009 by the Jinja Team. :license: BSD. """ -from jinja2 import Environment, DictLoader, TemplateSyntaxError +from jinja2 import Template, Environment, DictLoader, TemplateSyntaxError env = Environment() @@ -101,3 +101,36 @@ def test_stacked_locals_scoping_bug(): # endif ''') assert t.render(a=0, b=False, c=42, d=42.0) == '1111C' + + +def test_call_with_args(): + t = Template("""{% macro dump_users(users) -%} + + {%- endmacro -%} + + {% call(user) dump_users(list_of_user) -%} +
+
Realname
+
{{ user.realname|e }}
+
Description
+
{{ user.description }}
+
+ {% endcall %}""") + + assert [x.strip() for x in t.render(list_of_user=[{ + 'username':'apo', + 'realname':'something else', + 'description':'test' + }]).splitlines()] == [ + u'' + ]