Technotes

Technotes for future me

Jinja

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) %}
Last updated on 31 Jan 2021
Published on 24 Dec 2019
Edit on GitHub