【发布时间】:2015-09-16 08:06:30
【问题描述】:
让你假设我有这个 json 文件:
{
"components":[
{
"id" : "brandbar",
"name" : "brandbar.html",
"type":"navbar",
"description":"Bar with the brand",
"status": "draft"
},
{
"id":"topbar",
"type":"navbar",
"component":"Best brand",
"description":"Chart with Date"
}]
}
现在,我想在这个 json 上创建一个循环来检索文件名。
{% for entry in site.data.component.components %}
<div class="col-md-12">
{% include {{ entry.name }} %}
</div>
{% endfor %}
问题是我不能在我的 include 语句中使用 {{ entry.name }}。
有没有办法实现这个目标? 我不想直接在我的文件夹中循环...我想要一个主文件,我将在其中填写有关组件的每个重要属性。
【问题讨论】: