jinja Expressions

https://jinja.palletsprojects.com/en/master/templates/#expressions

jinja可以使用python相似的語法

Literals

表達式 描述
"Hello World" 字符串
42 / 123_456 整型
42.23 / 42.1e2 / 123_456.789 浮點型
['list', 'of', 'objects'] 列表
('tuple', 'of', 'values') 元組
{'dict': 'of', 'key': 'and', 'value': 'pairs'} 字典
true / false 布爾

Math

表達式 描述
+
-
/
//
%
*
**

Comparisons

表達式 描述
==
!=
>
>=
<
<=

邏輯

表達式 描述
and
or
not
(expr)

其他

表達式 描述
in
is test
| filter
~ 連接字符串,{{ "Hello " ~ name ~ "!" }} = Hello John!
()
. / []

內置過濾器

https://jinja.palletsprojects.com/en/master/templates/#list-of-builtin-filters

內置測試

https://jinja.palletsprojects.com/en/master/templates/#list-of-builtin-tests

全局方法

https://jinja.palletsprojects.com/en/master/templates/#list-of-global-functions

Extensions

https://jinja.palletsprojects.com/en/master/templates/#extensions

{{ … }} for Expressions to print to the template output

{{ foo.bar }}
{{ foo['bar'] }}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章