2014-02-27 45 views
1

我就不會到這裏來了,如果我沒有嘗試過許多不同的方法......增量值

顯然對象的集合確實有場大小/長度,但分量不有一個索引。我想是這樣的:

{% for product in contents.products %} 

<h3>Produkt {{ product.index + 1 }}</h3> 
<p>{{ product.price | concat: ' €' }}</p> 


{% endfor %} 

我已經試過這裏介紹以下: http://www.omniref.com/ruby/gems/locomotivecms-liquid/classes/Liquid::Increment

{% increment variable %} 

不工作。我必須在抱怨壞語法的後端編輯器中工作。未知的標籤增量。我可以使用舊版本嗎?不幸的是我無法檢查它。

我也試過之前在for循環分配的值改爲0:

{% assign x = 0 %} 

再經1手動增加它:

{% assign x = x + 1 %} 

一定有辦法!我的意思是這是基本的編程。有沒有人找到解決辦法? 謝謝!

回答

0

你可以做增量機車CMS是這樣的:

{% assign counter = 0 %} 
{% capture counter %}{{ counter | plus: 1 }}{% endcapture %}