Link Search Menu Expand Document

Jinja Cheat Sheet

This is a cheat sheet for the Jinja templating syntax.

Syntax

The syntax is somewhat similar to ERB except for {} instead of <> quotes

 {{ ... }}           # Escaping for expressions that create output
 {% ... %}           # Escaping for control statements
 # ... ##            # Line statements

Loops

 {% for i in list %} ... {% endfor %}

Functions

Defining functions

 {% macro myfunct(param1, param2) %}
 ...
 {% endmacro %}

Using functions

 {% myfunc(var, 5) %}