Skip to content
Myr

fixed a problem with having call blocks in outer scopes that

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

have an argument that is also used as local variable in an inner frame [#360]. --HG-- branch : trunk

authored by Armin Ronacher · committed by Armin Ronacher · parent a586989 · Browse files · 3 files+38 added−2 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+38 added−2 removed

  • tests:+34 added−1 removed
  • other:+4 added−1 removed

3 files+38 added−2 removed

modified:jinja2/compiler.py+1 added-1 removed
325 unmodified lines
326 """327 self.visit(node.iter)328329 def visit_CallBlock(self, node):330 for child in node.iter_child_nodes(exclude=('body',)):330 for child in node.iter_child_nodes(exclude=('body', 'args')):331 self.visit(child)332333 def visit_FilterBlock(self, node):334 self.visit(node.filter)
1216 unmodified lines
modified:tests/test_old_bugs.py+34 added-1 removed
6 unmodified lines
78 :copyright: (c) 2009 by the Jinja Team.9 :license: BSD.10"""11from jinja2 import Environment, DictLoader, TemplateSyntaxError11from jinja2 import Template, Environment, DictLoader, TemplateSyntaxError1213env = Environment()1415from nose import SkipTest
84 unmodified lines
100# print 'D'101# endif102''')103 assert t.render(a=0, b=False, c=42, d=42.0) == '1111C'104105106def test_call_with_args():107 t = Template("""{% macro dump_users(users) -%}108 <ul>109 {%- for user in users -%}110 <li><p>{{ user.username|e }}</p>{{ caller(user) }}</li>111 {%- endfor -%}112 </ul>113 {%- endmacro -%}114115 {% call(user) dump_users(list_of_user) -%}116 <dl>117 <dl>Realname</dl>118 <dd>{{ user.realname|e }}</dd>119 <dl>Description</dl>120 <dd>{{ user.description }}</dd>121 </dl>122 {% endcall %}""")123124 assert [x.strip() for x in t.render(list_of_user=[{125 'username':'apo',126 'realname':'something else',127 'description':'test'128 }]).splitlines()] == [129 u'<ul><li><p>apo</p><dl>',130 u'<dl>Realname</dl>',131 u'<dd>something else</dd>',132 u'<dl>Description</dl>',133 u'<dd>test</dd>',134 u'</dl>',135 u'</li></ul>'136 ]
modified:CHANGES+3 added
9 unmodified lines
10 identifier problems.11- include tags are now able to select between multiple templates12 and take the first that exists, if a list of templates is13 given.14- fixed a problem with having call blocks in outer scopes that15 have an argument that is also used as local variable in an16 inner frame [#360].1718Version 2.2.119-------------20(bugfix release, released on September 14th 2009)
114 unmodified lines