我在我的基本模板中包含一个模板,该模板被我渲染的模板所扩展。我在直接模板中设置了一个变量,并尝试在包含的模板中使用它。我希望以下内容输出Active
,但实际上没有任何输出。为什么header.html
无法看到变量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 %}