2017-04-03 69 views
1

我有以下幾點:嫩枝loop.first不工作​​

{% for field in fields -%} 
    <div class="item{% if loop.first %} active{% endif %}"> 
    {{ field.content }} 
    </div> 
{%- endfor %} 

但它的加入活性類各個領域的包裝,而不僅僅是其中第一個是我的本意。

+0

代碼只是[很好](https://twigfiddle.com/rsghhe),確定你沒有使用(舊)緩存版本?清除緩存或啓用'auto_reload' – DarkBee

回答

0

謝謝Darkbee。這裏的用戶故障。代碼位於嵌套模板文件(Drupal)中,我認爲自己正在迭代的循環實際上是在更高級別的模板文件中。

+0

你應該接受你的答案;) – Veve