I include the template in the base template, which the template I am issuing is expanding. I set the variable in the direct template and try to use it in the included template. I would expect the following to deduce Active, but instead there is no deduction. Why header.htmldoesn’t he see the variable Active?
main.py
@app.route("/")
def root():
return render_template("page.html")
page.html
{% set active = True %}
{% extends "base.html" %}
base.html
{% include "header.html" %}
header.html
{% if active %}Active{% endif %}
source
share