// 引入模板
{% include 'common/header.html' %}
// 移除空白
{% for item in seq -%}
{{ item }}
{%- endfor %}
// 循环序号
loop.index
loop.index0
loop.revindex
loop.revindex0
loop.first
loop.last
loop.length
loop.cycle
loop.depth
loop.depth0
// if判断
{% if 条件1 %}
语句块1
{% elif 条件2 %}
语句块2
{% else %}
不符合所有条件
{% endif %}
Python:Jinja2模板语法整理
关注
打赏