2013-02-20 28 views
0

是否有可能在jekyll中有一個值集合,然後將它們格式化爲表格?在jekyll中顯示值的集合

我想在我的.MD文件是這樣的:

--- 
layout: tutorial 
title: Jekyll 
reqs: 
- name: names here 
    desc: description here 
    value: value 
- name: names here 
    desc: description here 
    value: value 
--- 

在我的教程佈局我有這樣的:

--- 
layout: home 
--- 

{% for item in page.reqs %} 
    {{ item.name }} 
    {{ item.desc }} 
    {{ item.value }} 
{% endfor %} 

爲表中的HTML代碼已被刪除。問題是我的循環打印什麼都沒有。該頁面是空的,除了從其他佈局繼承的內容外。

回答

1

看起來像一個YAML問題。你在混合數組和字典語法。嘗試這樣的事情,而不是:現在

--- 
layout: tutorial 
title: Jekyll 
reqs: 
- item1: 
    name: names here 
    desc: description here 
    value: value 
- item2: 
    name: names here 
    desc: description here 
    value: value 
--- 

你的for循環在字典中的數組(item1, item2...),其值可以在你的輸出使用循環。