我需要在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扩展名:
但是,我收到了如下错误:
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'.
任何想法让这项工作? 谢谢。