bundled/jinja2/examples/basic/test_loop_filter.py @ 256716e3a3d7
webpy-sucks
Add Jinja2 as a bundled app.
author |
Steve Losh <steve@stevelosh.com> |
date |
Tue, 02 Mar 2010 19:49:35 -0500 |
parents |
(none) |
children |
(none) |
from jinja2 import Environment
tmpl = Environment().from_string("""\
<ul>
{%- for item in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] if item % 2 == 0 %}
<li>{{ loop.index }} / {{ loop.length }}: {{ item }}</li>
{%- endfor %}
</ul>
if condition: {{ 1 if foo else 0 }}
""")
print tmpl.render(foo=True)