Html 正确使用Jekyll中的数据
目标是在特定页面中使用在front matter部分中定义的变量 下面是我的文件系统结构: _组成部分Html 正确使用Jekyll中的数据,html,jekyll,liquid,Html,Jekyll,Liquid,目标是在特定页面中使用在front matter部分中定义的变量 下面是我的文件系统结构: _组成部分 c1.html c2.html 在这里,我定义了前面事项中的属性 _包括>组件 c1.html 这里我想使用一个循环来引用_Components>c1.html页面中定义的变量 我怎样才能达到这个目标 在my_Includes>Components>c1.html中,我有以下代码: <body class="full"> {% assign fullcomponen
- c1.html
- c2.html
- c1.html
<body class="full">
{% assign fullcomponents = site.components %}
{% for component in fullcomponents | where:"title","c1html" %}
{% component.title %}
{% endfor %}
<div class="container-fluid" id="componentscontainer">
<div class="col-md-12">
<div class="panel panel-primary" id ="panelcomponentlarge">
<div class="panel-heading" >
Chart C3 Line
</div>
etc...
{% assign comp = site.data.components.Components[ChartC3Line] %}
HTML:
{% highlight html linenos%}
<p> Description: {{ comp.description }} </p>
我试图通过以下代码获取这些信息:
<body class="full">
{% assign fullcomponents = site.components %}
{% for component in fullcomponents | where:"title","c1html" %}
{% component.title %}
{% endfor %}
<div class="container-fluid" id="componentscontainer">
<div class="col-md-12">
<div class="panel panel-primary" id ="panelcomponentlarge">
<div class="panel-heading" >
Chart C3 Line
</div>
etc...
{% assign comp = site.data.components.Components[ChartC3Line] %}
HTML:
{% highlight html linenos%}
<p> Description: {{ comp.description }} </p>
我不想让一个对象包含一个元素的多个数组!
下面是检索正确信息的代码:
{% assign comp = site.data.components.ChartC4[0] %}
HTML:
{% highlight html linenos%}
<p> Description: {{ comp.description }} </p>
{%assign comp=site.data.components.ChartC4[0]}
HTML:
{%highlight html linenos%}
说明:{{comp.Description}}
已解决
按照json文件的结构,我以更简单的方式更改了结构:
{
}
现在我可以很容易地访问正确的对象
{%assign comp=site.data.components.ChartC3%}
HTML:
{% highlight html linenos%}
<p> Description: {{ comp.description }} </p>
HTML:
{%highlight html linenos%}
说明:{{comp.Description}}
HTML:
{% highlight html linenos%}
<p> Description: {{ comp.description }} </p>