根据列表长度返回条件if语句

ali*_*s51 -3 python jinja2

我正在尝试创建一个条件if函数,如果列表的长度大于5,则显示结果:

{% if length(photos) > 5 %}
...
{% endif %}
Run Code Online (Sandbox Code Playgroud)

但是,我知道Could not parse the remainder: '(photos)' from 'length(photos)',我哪里错了?

谢谢

Ash*_*ary 8

正确的语法是:

{% if photos|length > 5 %}
...
{% endif %}
Run Code Online (Sandbox Code Playgroud)