summaryrefslogtreecommitdiffstats
path: root/examples/basic/cycle.py
blob: 1f97e37945ca3968644a6f4586836abd8aa0e7d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
from jinja2 import Environment

env = Environment(
    line_statement_prefix="#", variable_start_string="${", variable_end_string="}"
)
print(
    env.from_string(
        """\
<ul>
# for item in range(10)
    <li class="${loop.cycle('odd', 'even')}">${item}</li>
# endfor
</ul>\
"""
    ).render()
)