如何包含烧瓶蓝图的模板?

时间:2020-03-26 20:01:13

标签: python flask

想象一个带有一个蓝图的基本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.htmlblueprint-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/目录中?

0 个答案:

没有答案