【发布时间】:2014-02-04 20:02:36
【问题描述】:
我有两个循环遍历的数组,但它们是嵌套的。 降到最低,看起来是这样的:
{% for item in items %}
<label>{{ item.name }}</label>
<select>
{% for attribute in attributes %}
<option>{{ attribute.name }}</option>
{% endfor %}
</select>
{% endfor %}
问题在于数组的大小。大约有 1,100 个items 和 400 个attributes。可以猜到,这很慢。很慢。
是否可以“存储” 内部循环,然后重用生成/渲染的块?
【问题讨论】:
-
哦,对不起。我为这个问题设置了电子邮件信息,但没有得到。我今天下班后试试。我一直在寻找类似的东西,但我看起来很有希望。今天晚些时候,我会告诉你这对我有用。
标签: for-loop twig template-engine