如何在jinja2中导入loopcontrol

时间:2016-04-29 14:04:50

标签: python jinja2

我需要在jinja2中使用break for for循环。 以下是我的代码:

{% for i in range (0, desc) %}{{ desclist[i] }} {% set length = length + desclist[i]|length %}{% if length >= 70 %}{% break %}{% endif %}{% endfor %}

并导入loopcontrol扩展名:

enter image description here

但是,我收到了如下错误:

jinja2.exceptions.TemplateSyntaxError: Encountered unknown tag 'break'.
Jinja was looking for the following tags: 'elif' or 'else' or 'endif'. The
innermost block that needs to be closed is 'if'.

任何想法让这项工作? 谢谢。

0 个答案:

没有答案