templating

Jinja2 is the flask templating languagearrow-up-right; heavily inspired by Python and Django

Template Variables are passed in as named parameters by the render_template ft

Basics

{{ to insert }}

`

`

{# comment #}

Control

{% for topic in NAVBAR_LIST %}
    <div> {{topic}} </div>
    <div> {{topic}} </div>
{% endfor %}
{% if variable is defined %}
    value of variable: {{ variable }}
{% else %}
    variable is not defined
{% endif %}

Filters

Basically pipes like helpers in handlebars

{{ companies|tojson }} #turn companies into json

BLOCKS

Extend to leave common elements

You can override and fill in blocks

layout.html

index.html

Macros

The macro can then be called like a function in the namespace:

Linking with url_for

No Blueprint

If there was a blueprint named main, us'main.login'

Last updated