任何人都知道在 Twig/Swig 中执行此操作的干净方法:
{% for(i = 0; i < 100; i++) %}
blah....
{% endfor %}
如果你有一个数字,那么你可以将其转换为数组,然后使用 Swig 的标签标准。如果您总是想从 0 开始循环,这是最简单的。
例如:
{% set productCount = 6 %}
{% set productCountAsArray = Array(productCount) %}
{# This will run productCount times #}
{% for x, y in productCountAsArray %}
This is for number: {{ x }}
{% endfor %}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)