使用 Twig 或 Swig 的 for 循环计数器 [英] for loop counter with Twig or Swig
本文介绍了使用 Twig 或 Swig 的 for 循环计数器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
任何人都知道在 Twig/Swig 中执行此操作的干净方法:
Anyone know of a clean way to do this in Twig/Swig:
{% for(i = 0; i < 100; i++) %}
blah....
{% endfor %}
推荐答案
对于twig其:
{% 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
所以我想将痛饮部分传递给下一个.
so i would like to pass the swig part to the next one.
这篇关于使用 Twig 或 Swig 的 for 循环计数器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文