Skip to content
Myr

Automated merge with ssh://team@pocoo.org/jinja2-main

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 · parents d55ab53, f9f029c · Browse files · 2 files+14 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

2 files+14 added−3 removed

  • other:+14 added−3 removed

2 files+14 added−3 removed

modified:jinja2/runtime.py+1 added-1 removed
172 unmodified lines
173 try:174 value = self.defaults[idx - arg_count]175 except IndexError:176 value = Undefined(name)177 arguments['l_' + name] = arg177 arguments['l_' + name] = value178 if self.catch_all:179 arguments['l_arguments'] = kwargs180 return u''.join(self.func(**arguments))181
31 unmodified lines
modified:test.py+13 added-2 removed
1import sys 2from jinja2 import Environment3from jinja2.compiler import generate45
3 unmodified lines
9 {% b = 23 %}10 {% macro foo(a) %}[{{ a }}|{{ b }}|{{ c }}]{% endmacro %}11 {% for item in seq %}12 {{ foo(item) }}12 {% endfor %}13 {%- endfor %}14{% endblock %}15""")16print ast17print17print generate(ast, env, "foo.html")18source = generate(ast, env, "foo.html")19print source20print2122# execute the template23code = compile(source, 'jinja://foo.html', 'exec')24context = {'seq': range(5), 'c': 'foobar'}25namespace = {'global_context': context}26exec code in namespace27for event in namespace['root'](context):28 sys.stdout.write(event)