Jinja2 Inheritance with Blocks and Includes

做~自己de王妃 提交于 2019-12-03 01:41:37

base.html is not rendered because it's not invoked by any template. What you could do is a second level of extension:

base.html:

<html>{% block html %}{% endblock %}</html>

content.html:

{% extends "base.html" %}
{% block html %}
<h1>{% block title %}Title{% endblock title%}</h1>
<div>{% block content_body %}Content Body{% endblock content_body%}</div>
{% endblock %}

Still, that is probably overkill, you will likely find that a single base template is enough (i.e. combine base.html and content.html into a single template).

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