Megacorp Documentation v2.0-beta

Note

Page source: jinja/loops.rst — release 0.1.

This box is written once, in _templates/page_header.rst, and rendered into every page that includes it. page comes from the {% set %} at the top of the including document; release comes from the library's jinja_context.

Generating Repetitive Content

The other thing projects template for: writing a table or a list once and letting the loop repeat it.

{% for name, purpose in [("srcs", "the documents"),
                       ("parse_data", "the files the parser reads")] %}
``{{ name }}``
    {{ purpose }}
{% endfor %}

renders as the definition list below.

srcs

the documents this library publishes

parse_data

the files the parser reads while parsing them

images

the pictures its pages show

Every generated line traces back to the line of the template that generated it, so a mistake inside a loop body is reported once per iteration, on the line that was actually written.