-2
我试图创建一个条件if
函数,它显示的结果,如果该列表的长度大于5:返回条件
{% if length(photos) > 5 %}
...
{% endif %}
不过,我得到Could not parse the remainder: '(photos)' from 'length(photos)'
,其中我错了吗?
感谢
我试图创建一个条件if
函数,它显示的结果,如果该列表的长度大于5:返回条件
{% if length(photos) > 5 %}
...
{% endif %}
不过,我得到Could not parse the remainder: '(photos)' from 'length(photos)'
,其中我错了吗?
感谢
正确的语法是:
{% if photos|length > 5 %}
...
{% endif %}
不Python中使用'LEN()'为长度的功能,而不是'长度()'? – Conduit 2014-10-03 17:51:43
@Conduit OP在这里询问Jinja模板引擎,而不是Python。 – 2014-10-03 17:56:01
@AshwiniChaudhary哎呀!误导Python标签 - 抱歉,OP。 – Conduit 2014-10-03 19:24:05