簡體   English   中英

為什么液體/ jekyll會插入代碼標簽,如何刪除它們?

[英]Why are code tags being inserted by liquid/jekyll and how do I remove them?

我想為我正在使用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 %}
{% assign recent_leader = site.data.leaders[dedupped_leader] %}

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

如果在markdown文件中執行此操作,它將輸出代碼塊( 請參閱kramdown文檔

如果您不希望代碼塊,請執行以下操作:

沒有縮進的行后沒有換行

{% 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 }}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM