You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<!DOCTYPE html><html><head><title>xxxxx</title></head><body><p>Dear {{ person_name }},</p><p>Thanks for placing an order from {{ company }}. It's scheduled to ship on {{ ship_date|date:"F j, Y" }}.</p><p>Here are the items you've ordered:</p><ul>
{% for item in item_list %}
<li>{{ item }}</li>
{% endfor %}
</ul>
{% if order_warranty %}
<p>Your warranty information will be included in the packaging.</p>
{% endfor %}
<p>Sincerely, <br />{{ company }}</p></body></html>
模板本质是 HTML,中间夹杂了一些变量和模板标签
{{}} 包围的是 变量
过滤器: {{ship_date|date:"F j, Y"}} 把 ship_date 变量传递给过滤器,并给 date 过滤器传递了一个参数 F j, Y, date 过滤器以给定参数的形式格式化日期,类似于 Unix,过滤器使用管道字符 |
0x01 Django
模板(
templates
)string
文本,它用来分离一个文档的展现和数据placeholder
和表示多种逻辑的tags
来规定文档如何展现HTML
,Django
模板也能生成其他基于文本的形式模板本质是
HTML
,中间夹杂了一些变量和模板标签{{}}
包围的是变量
{{ship_date|date:"F j, Y"}}
把ship_date
变量传递给过滤器,并给date
过滤器传递了一个参数F j, Y
,date
过滤器以给定参数的形式格式化日期,类似于Unix
,过滤器使用管道字符|
{{%%}}
包围的是块标签
块标签
的含义很丰富,它告诉模板系统做一些事情if
for
逻辑语句,这样的功能都是块标签
The text was updated successfully, but these errors were encountered: