💭 Template Designer Documentation — Jinja Documentation

!https://jinja.palletsprojects.com/en/3.1.x/templates/#include

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.

Note

This post is a thought. It’s a short note that I make about someone else’s content online #thoughts

Connections

Related tags and posts connected to this entry.