
本文共 2516 字,大约阅读时间需要 8 分钟。
���������������������������������
1. ���������
������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������
1.1 ���������������
������������������������ Python ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������
������������������������������������������
1.1.1 ���������������
���������������������������������������������������������������������������������
{Variable | filter_name(*args, **kwargs)}
������������������������������������������������������������������������������������������
{Hello | capitalize} { Hello | trim } {hello | reverse}
1.1.2 ������������������
������������������������������������������������������������������������ {% %}
������������������������������������������������������
{% filter upper %}This is a test content!
{% endfilter %}
1.1.3 ������������������
���������������������������������������������������������������������������������������������������������������������������
@app.template_filter('md')def md_to_html(txt): return markdown(filtered_text)
1.2 ���������������
������������������������������������������
-
���������������
{12.8888 | round}
-
������������������������
{12.8888 | round(2, 'floor')}
-
���������������������
{XML | lower}
-
������������������
{' hello ' | trim}
-
���������������
[3, 2, 1, 5, 4] | sort
2. ���������
���������������������������������������������������������������������������������������������������������������������������
2.1 ���������������
������������������ if
������������������������������������������������������������
{% if name is defined %}Name is defined
{% endif %}
2.2 ���������������
���������������������������������������������������������
-
���������������������
{% if name is defined %}
-
������������������������
{% if name is string %}
-
������������������������������
{% if [1,2,3] is iterable %}
-
���������������������
{% if {'name':'test'} is mapping %}
2.3 ������������������
���������������������������������������������������������������������������
@app.template_test('is_even')def is_even(num): return num % 2 == 0
������
���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������
发表评论
最新留言
关于作者
