所以我试图在我的网站的每个页面上添加页脚和标题.我制作了一个base.html文件,其中包含网站的总体布局.
在我的about.html页面中,我做了:
{% extends "public/base.html" %}
<h1>Content goes here</h1>
Run Code Online (Sandbox Code Playgroud)
我可以看到我的页眉和页脚,但如何显示内容.我想在about.html页面中输入内容.这里的内容没有显示在中间.
Dan*_*man 30
您需要在base.html中定义一个块并在about.html中填充它.
base.html文件:
<header>...</header>
{% block content %}{% endblock %}
<footer>...</footer>
Run Code Online (Sandbox Code Playgroud)
about.html
{% extends "public/base.html" %}
{% block content %}
<h1>Content goes here</h1>
{% endblock %}
Run Code Online (Sandbox Code Playgroud)
这一点在本教程中都有详细解释.
{% extends "public/base.html" %}
{% block content %}
<h1>Content goes here</h1>
{% endblock %}
Run Code Online (Sandbox Code Playgroud)
或者只是about.html在主html中创建并包含它.
例:
{% extends "public/base.html" %}
{% block content %}
"Your code"
{% include "core/about.html" %}
{% endblock %}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
25064 次 |
| 最近记录: |