1. 程式人生 > >html的extends和include

html的extends和include

.html include round utf-8 extend pad com 頁面 nbsp

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 %}

html的extends和include