我需要将块从基本模板传递到包含上下文的模板,但不希望
这些块在基本模板中重叠。例如,我有几个模板
header.html
<header>
<title>{% block title %}{% endblock %}</title>
</header>
body1.html
{% include "test_header.html" ignore missing with context %}
{% block title %}Title1{% endblock %}
<body>
Hello
</body>
body2.html
{% include "test_header.html" ignore missing with context %}
{% block title %}Title2{% endblock %}
<body>
Hello
</body>
当我尝试呈现 body1.html 时,页面标题重命名为“Title1”,但块标题呈现两次并在正文中显示 Title1。我如何才能将这个上下文准确地传递给 include 语句?