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!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.