How do I include a HTML file in a Jinja2 template? How do I include a HTML file in a Jinja2 template? python python

How do I include a HTML file in a Jinja2 template?


Use the jinja2 {% include %} directive.

{% extends 'template.html' %}{% block content %}    {% if task == 'content1' %}        {% include 'content1.html' %}    {% endif %}    {% if task == 'content2' %}        {% include 'content2.html' %}    {% endif %}{% endblock %}

This will include the content from the correct content-file.