2017-04-12 44 views
0

給定數量的offices文件夾內的文件降價,我需要遍歷每個人,並找到所有城市/渲染城市值,其中狀態是一個給定值。到目前爲止,我有這個,但是不管在where子句中它使得每一個城市:遍歷職位和過濾,其中狀態被確定

<ul class="cities"> 
{% for post in site.offices | where: "state", "florida" %} 
    <li>{{ post.title }}</li> 
{% endfor %} 
</ul> 

<li>{{ post.title }}</li應列出所有這一切都爲佛羅里達州的降價文件的城市。

這是一個示例文件降價:

--- 
office_id: 5 
title: Orlando 
state: florida 
phone: 123-456-7890 
--- 

回答

1

我發現我必須設置分配第一:

{% assign cities = (site.offices | where: "state" , "florida") %} 
    {% for city in cities %} 
    <li>{{ city.title }}</li> 
    {% endfor %}