Is it possible to perform Includes with flask?

◇◆丶佛笑我妖孽 提交于 2019-12-18 05:28:05

问题


Say I have a template layout saved in template.html. This template includes a banner, side navigation, content container, and footer. Can I use flask to break up these page elements in such a way that I can have files such as banner.html, sidenavigation.html, etc. and render these different files within template.html?


回答1:


From: http://jinja.pocoo.org/docs/templates/#include

template.html

{% include 'banner.html' %}
{% include 'sidenavigation.html' %}
{% include 'content.html' %}
{% include 'footer.html' %}



回答2:


By default, Flask uses Jinja2 as its template engine. See Jinja's Template Designer Documentation how it's done.



来源:https://stackoverflow.com/questions/9679038/is-it-possible-to-perform-includes-with-flask

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!