twig中使用continue和break

2,958次阅读

共计 309 个字符,预计需要花费 1 分钟才能阅读完成。

Break

{% set break = false %}
{% for post in posts if not break %}

{{post.heading}}

{% if post.id == 10 %}
{% set break = true %}
{% endif %}
{% endfor %}

Continue

{% set continue = false %}
{% for post in posts %}
{% if post.id == 10 %}
{% set continue = true %}
{% endif %}
{% if not continue %}

{{post.heading}}

{% endif %}
{% if continue %}
{% set continue = false %}
{% endif %}
{% endfor %}

正文完
 0
Blood.Cold
版权声明:本站原创文章,由 Blood.Cold 于2019-06-03发表,共计309字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。