March 2019
Intermediate to advanced
412 pages
9h 49m
English
A loop allows you to build dynamically created sections in template files, and is useful when you know you need to operate on an unknown number of items in the same way. To start a loop control structure, the for statement is used. Let's look at a simple way to loop over a list of directories where a fictional service might find data:
# data dirs
{% for dir in data_dirs -%}
data_dir = {{ dir }}
{% endfor -%}
In this example, ...
Read now
Unlock full access