Posts tagged: jinja2

All posts with the tag "jinja2"

1 posts latest post 2023-07-28

A feature of jinja that I just discovered is including sub templates. Here is an example from the docs.

{% include 'header.html' %} Body goes here. {% include 'footer.html' %}

And inside of my thoughts project I used it to render posts.

<ul id='posts'> {% for post in posts.__root__ %} {% include 'post_item.html' %} {% endfor %} </ul>

note that post_item.html automatically inherits the post variable.