【发布时间】:2014-05-28 14:37:54
【问题描述】:
我有一个关于 Jekyll Liquid 的问题。
我有布局,我想在其中显示类别中的页面。为了显示类别,我使用 page.categories 变量。当我在括号中显示时 {{page.categories}} 是正确的。 但我不知道,如何传递给循环?
{% for post in site.categories[page.categories] %}
<li><a href="{{ post.url }}">{{ post.title }}</a></li>
{% endfor %}
{% for post in site.categories[{{page.categories}}] %}
<li><a href="{{ post.url }}">{{ post.title }}</a></li>
{% endfor %}
不工作。
如果我通过了显式:
{% for post in site.categories['cat1'] %}
<li><a href="{{ post.url }}">{{ post.title }}</a></li>
{% endfor %}
有效。
我发现了另一个话题:
Jekyll site.categories.{{variable}}?
但它不起作用。
【问题讨论】: