Jekyll在三维数组上迭代
我使用Jekyll 3.3在Jekyll在三维数组上迭代,jekyll,liquid,Jekyll,Liquid,我使用Jekyll 3.3在\u config.yml文件中创建了一个数组: profiles: - user1: - username: "test" - link: "http://test.test" 我想获得每个用户的值用户名和链接。所以我使用了一个双循环: {% for profile in site.profiles %} {% for user in profile %} {{ user.username }} {% endf
\u config.yml
文件中创建了一个数组:
profiles:
- user1:
- username: "test"
- link: "http://test.test"
我想获得每个用户的值用户名
和链接
。所以我使用了一个双循环:
{% for profile in site.profiles %}
{% for user in profile %}
{{ user.username }}
{% endfor %}
{% endfor %}
但这并没有打印任何内容,我遗漏了什么吗?数据排列如下:
profiles:
- username: "test"
link: "http://test.test"
- username: "test2"
link: "http://test.test2"
你可以做:
{% for user in site.profiles %}
<a href="{{ user.link }}">{{ user.username }}</a>
{% endfor %}
{%用于site.profiles%中的用户]
{%endfor%}