我有一個數據文件,其中包含我想要在Jekyll中使用指定索引的對象。如何在Jekyll中使用變量作爲數組索引包括
我的頁面調用包括像這樣:
{% include components/header-filter.html items="0" %}
哪裏0
是我想在這種情況下使用索引。
我include是:
{% assign filterID = include.items %}
{% capture id %}{{ filterID }}{% endcapture %}
{% assign filter = site.data.filters[id] %}
這工作,直到它到達3號線,此時它什麼也不輸出。
我在做什麼錯?
乾杯!
感謝您的幫助!這是第一個問題,當我只想要數字時,它將0當作字符串處理。 – privatemachine