render templates
--HG--
branch : trunk
diff --git a/jinja2/runtime.py b/jinja2/runtime.py
index 0e42005..cc5cfe1 100644
--- a/jinja2/runtime.py
+++ b/jinja2/runtime.py
@@ -149,7 +149,7 @@
class Macro(object):
"""
- Wraps a macor
+ Wraps a macro
"""
def __init__(self, func, name, arguments, defaults, catch_all):
@@ -176,7 +176,7 @@
value = self.defaults[idx - arg_count]
except IndexError:
value = Undefined(name)
- arguments['l_' + name] = arg
+ arguments['l_' + name] = value
if self.catch_all:
arguments['l_arguments'] = kwargs
return u''.join(self.func(**arguments))
diff --git a/test.py b/test.py
index 67f19b6..7ab5b96 100644
--- a/test.py
+++ b/test.py
@@ -1,3 +1,4 @@
+import sys
from jinja2 import Environment
from jinja2.compiler import generate
@@ -9,9 +10,19 @@
{% macro foo(a) %}[{{ a }}|{{ b }}|{{ c }}]{% endmacro %}
{% for item in seq %}
{{ foo(item) }}
- {% endfor %}
+ {%- endfor %}
{% endblock %}
""")
print ast
print
-print generate(ast, env, "foo.html")
+source = generate(ast, env, "foo.html")
+print source
+print
+
+# execute the template
+code = compile(source, 'jinja://foo.html', 'exec')
+context = {'seq': range(5), 'c': 'foobar'}
+namespace = {'global_context': context}
+exec code in namespace
+for event in namespace['root'](context):
+ sys.stdout.write(event)