-
Notifications
You must be signed in to change notification settings - Fork 2
/
template.html
91 lines (74 loc) · 2.58 KB
/
template.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<!DOCTYPE html>
<html lang="en">
<head>
<title>{{ title }}</title>
</head>
<body>
<ul id="navigation">
{% for item in navigation %}
<li><a href="{{ item.href }}">{{ item['caption'] }}</a></li>
{% endfor %}
</ul>
<h1>My Webpage</h1>
{{ a_variable }}
{# a comment #}
<!-- 调用内置函数方法 -->
##--------------------------------------------------------------------
{{ a_variable|striptags|title }}
{{ [1, 3, 3]|join('/ ') }}
<!-- 判断是否存在变量 -->
##--------------------------------------------------------------------
{% if variable is defined %}
value of variable: {{ variable }}
{% else %}
variable is not defined
{% endif %}
<!-- 注释 -->
##--------------------------------------------------------------------
{# note: commented-out template because we no longer use this
{% for user in users %}
...
{% endfor %}
#}
<!-- 空白与换行 -->
{# 删除首尾的空白和换行 #}
##--------------------------------------------------------------------
{% for item in navigation -%}
<span>{{ item['caption'] }}</span>
{%- endfor %}
-----------------------------------------
{# 删除首尾的空白和换行 #}
{%- if title -%}
<div>{{ title }}</div>
{%- endif -%}
{# 输出代码语句块 #}
##--------------------------------------------------------------------
{% raw %}
<ul>
{% for item in navigation %}
<li>{{ item }}</li>
{% endfor %}
</ul>
{% endraw %}
{# 行语句的使用,需要开启配置 #}
##--------------------------------------------------------------------
<ul>
# for item in seq:
<li>{{ item }}</li> ## 注释内容
# endfor
</ul>
<ul>
{% for item in seq %}
<li>{{ item }}</li>
{% endfor %}
</ul>
{# 行语句大括号跨行使用 #}
##--------------------------------------------------------------------
<ul>
# for href, caption in [('index.html', 'Index'),
('about.html', 'About')]:
<li><a href="{{ href }}">{{ caption }}</a></li>
# endfor
</ul>
</body>
</html>