天天看點

Python:Jinja2模闆文法整理

// 引入模闆
{% 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 %}