summaryrefslogtreecommitdiffstats
path: root/examples/basic/cycle.py
diff options
context:
space:
mode:
Diffstat (limited to 'examples/basic/cycle.py')
-rw-r--r--examples/basic/cycle.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/examples/basic/cycle.py b/examples/basic/cycle.py
new file mode 100644
index 0000000..1f97e37
--- /dev/null
+++ b/examples/basic/cycle.py
@@ -0,0 +1,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()
+)