for 带有 Twig 或 Swig 的循环计数器 [英] for loop counter with Twig or Swig

查看:27
本文介绍了for 带有 Twig 或 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆