为什么代码标签被liquid / jekyll插入,我该如何删除它们?

时间:2015-02-05 01:18:12

标签: jekyll liquid

我想为我正在使用Jekyll开发的博客创建最近作者的列表。

我列出了最近的作者,并在yml数据表中查找了每个项目,我已经设置了列出每个作者及其生物,姓名和电子邮件等。

我能够提取我想要的信息,但是当它在浏览器中呈现时,它位于<code>个标签之间。

问题位是

{% assign recent_leader = site.data.leaders[dedupped_leader] %}

        {{ recent_leader.name }}
        {{ recent_leader.bio }}

assign语句似乎会导致整个循环内容掉入代码块。

如何摆脱<code>标签?我想知道某个地方是否只有逗号,或者... ...

以下是该页面的其余代码。

{% comment %}First loop captures leaders from the last three months {% endcomment %}

{% for post in site.posts %}

 {% capture postDateSeconds %}{{post.date | date: "%s"}}{% endcapture %} 
 {% capture siteTimeMinusTwelveWeeks %}{{site.time | date: "%s" | minus: 7260000}}
 {% endcapture %}

{% if postDateSeconds >= siteTimeMinusTwelveWeeks and post.date <= site.time %}
 {% capture indexes %}{{ indexes | append: forloop.index | append: "," }}{% endcapture %}
 {% capture leaders %}{{ leaders | append: post.leader | append: "," }}{% endcapture %}
{% endif %}
{% endfor %}



{% comment %}Split the captured loop into its own array {% endcomment %}

{% assign leaders_array = leaders | split: "," %}


{% comment %} initialise a new array for dedupped list{% endcomment %}

{% assign dedupped_leaders = "" %}

{% comment %} if the leaders name is in the new array already remove it. Then add the name. This makes sure the name is on the list just once. {% endcomment %}

{% for leader in leaders_array %}

{% if dedupped_leaders contains leader %}
{% assign leader_and_comma = leader | append: "," %}
{% capture dedupped_leaders %}{{dedupped_leaders | remove_first: leader_and_comma }}{% endcapture %}
{% endif %}
{% capture dedupped_leaders %}{{dedupped_leaders | append: leader | append: ","}}{% endcapture %}


{% endfor %}


{% comment %}Split the captured loop into its own array {% endcomment %}

{% assign dedupped_leaders_array = dedupped_leaders | split: "," %}

{% for dedupped_leader in dedupped_leaders_array %}

{% assign recent_leader = site.data.leaders[dedupped_leader] %}

        {{ recent_leader.name }}
        {{ recent_leader.bio }}

{% endfor %}

1 个答案:

答案 0 :(得分:1)

{% assign recent_leader = site.data.leaders[dedupped_leader] %}

        {{ recent_leader.name }}
        {{ recent_leader.bio }}

如果您在降价文件中执行此操作,它将输出代码块(see kramdown documentation

如果您不想要代码阻止,请执行:

没有缩进行后没有换行

{% assign recent_leader = site.data.leaders[dedupped_leader] %}
    {{ recent_leader.name }}
    {{ recent_leader.bio }}

两个空格缩进

{% assign recent_leader = site.data.leaders[dedupped_leader] %}

  {{ recent_leader.name }}
  {{ recent_leader.bio }}