1from jinja2 import Environment
2
3tmpl = Environment().from_string(
4    """\
5<ul>
6{%- for item in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] if item % 2 == 0 %}
7    <li>{{ loop.index }} / {{ loop.length }}: {{ item }}</li>
8{%- endfor %}
9</ul>
10if condition: {{ 1 if foo else 0 }}
11"""
12)
13print(tmpl.render(foo=True))
14