for 带有 Twig 或 Swig 的循环计数器 [英] for loop counter with Twig or Swig
问题描述
任何人都知道在 Twig/Swig 中执行此操作的干净方法:
Anyone know of a clean way to do this in Twig/Swig:
{% for(i = 0; i < 100; i++) %}
blah....
{% endfor %}
推荐答案
对于 twig its:
For twig its:
{% for i in 0..100 %}
* {{ i }}
{% endfor %}
来自 http://twig.sensiolabs.org/doc/tags/for.html
对于 swig,文档还没有提到它:https://github.com/paularmstrong/swig/blob/master/docs/tags.md#for
For swig the docs dont mention it yet: https://github.com/paularmstrong/swig/blob/master/docs/tags.md#for
我真的说不出来,但 swig 可能不支持它,因为它受 django 启发,而且 django 似乎也天生缺乏此功能:https://code.djangoproject.com/ticket/5172
i cant really tell but it might be not supported in swig since its django inspired and django also seems to lack this feature nativly: https://code.djangoproject.com/ticket/5172
所以我想把swig部分传递给下一个.
so i would like to pass the swig part to the next one.
这篇关于for 带有 Twig 或 Swig 的循环计数器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!