想象一个带有一个蓝图的基本Flask项目设置。
app/
my_blueprint/
templates/
blueprint-template-1.html
blueprint-template-2.html
include.html # <-- notice this
static/
blueprint.py
...
__init__.py
templates/
static/
现在想象一下,该蓝图具有两条分别渲染blueprint-template-1.html
和blueprint-template-2.html
的路线。
...
@my_blueprint.route("/1")
def _route_1():
render_template("blueprint-template-1.html")
@my_blueprint.route("/2")
def _route_2():
render_template("blueprint-template-2.html")
现在想象一下,您想include
跨这些模板中的一个蓝图模板。
<!--- blueprint-template-1.html -->
...
{% include "include.html" %}
和
<!--- blueprint-template-2.html -->
...
{% include "include.html" %}
如何指定要包含在蓝图的templates/
而非主templates/
目录中?