Learning Jinja2: Part 5: Control Blocks

Learning Jinja2

Jinja2 is a template engine for Python featuring an optional sandbox environment.

Control Blocks

Along with using variables and building off files, Jinja2 also has functionality for using loops.

The keywords for… in work in Jinja2 and serve as a way to move through data structures like Lists in Python. This creates a control block that “controls” how things are shown.


Conditional statements are also supported in Jinja2. They use the keywords if and endif.

Play with the example on Repl.it!