be an expression. As soon as you specify an expression as second argument
the closing tag has to be omitted.
+- It's now possible to iterate over iterators additionally to sequences.
+ If the iterator is inifite it will crash however, so makes sure you don't
+ pass something like that to a template!
+
Version 1.0
-----------
CYCLING = '''{% for item in seq %}{% cycle '<1>', '<2>' %}{% endfor %}\
{% for item in seq %}{% cycle through %}{% endfor %}'''
SCOPE = '''{% for item in seq %}{% endfor %}{{ item }}'''
+VARLEN = '''{% for item in iter %}{{ item }}{% endfor %}'''
def test_simple(env):
tmpl = env.from_string(SCOPE)
output = tmpl.render(seq=range(10))
assert not output
+
+
+def test_varlen(env):
+ def inner():
+ for item in range(5):
+ yield item
+ tmpl = env.from_string(VARLEN)
+ output = tmpl.render(iter=inner())
+ assert output == '01234'