base.html内容
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <style> * { margin: 0; padding: 0; } </style> </head> <body> {% include 'include.html' %} 调用include.html模板 -----------------Name-------------------<br> <p>{% block name %} block块 取名为name {% endblock %}</p> </body> </html>
extends页面内容:
{% extends 'base.html' %}
{% block name %}
唐某人(替换base.html的 block块下的内容)
{% endblock %}
include页面内容:
<b>这是include调用的内容</b>
ps: extends时,不能include,但是可以在extends的块里面include
{% extends 'base_for_extend.html' %}
{% block name %}
唐某人{% include 'include_for_basse_extend.html' %} {# 需要include块里面才有效 #}
{% endblock %}
HTML的注释语法
{# 单个注释 #}
-------------------------------------------------------------------------
{% comment %}
段落注释
{% endcomment %}