Jekyll “杰基尔”;“液体语法错误”;有限度

Jekyll “杰基尔”;“液体语法错误”;有限度,jekyll,liquid,Jekyll,Liquid,我不知道这里出了什么问题,我还有其他几段相同结构的代码,但它们没有返回这个错误 下面是HTML文件(item.HTML)中我遇到问题的液体代码: {% assign item-collection = site.item-collection | sort: 'date' | reverse %} {% for item in item-collection %} {% if item.featured == true limit: 3 %} <div class="item"

我不知道这里出了什么问题,我还有其他几段相同结构的代码,但它们没有返回这个错误

下面是HTML文件(item.HTML)中我遇到问题的液体代码:

{% assign item-collection = site.item-collection | sort: 'date' | reverse %}
{% for item in item-collection %}
  {% if item.featured == true limit: 3 %}
    <div class="item">
    </div>
  {% endif %}
{% endfor %}
以下是终端返回的错误:

Regenerating: 1 file(s) changed at 2017-06-28 22:41:16     Liquid Warning: Liquid syntax error (line 30): Expected end_of_string but found id in "item.featured == true limit: 3" in /_layouts/item.html ...done in 1.337976 seconds.
如果我将日期留空,则不会发生此错误,但一旦输入某个内容,此错误将停止站点的构建

如果我从液体代码中删除“limit:3”,错误也会消失,但我需要这个限制

你知道我做错了什么吗?
提前谢谢

限制
是标签参数的
。它在特定索引处退出for循环

if
标记后使用它并不意味着什么,而且在处理它时会让Jekyll感到困惑

limit
标记移动到
for
循环行,它应该只迭代前三项

{% for item in item-collection limit: 3 %}
 {% if item.featured  %}
基于评论的更新
  • 按特征标记筛选项目

    {% assign item-collection = site.item-collection | where_exp:"item","item.featured == true" %}
    
  • 按日期对结果排序

    {% assign item-collection = item-collection | sort: 'date' | reverse %}
    
  • 将列表限制为3篇特色文章

    <ul>
    {% for item in item-collection limit:3 %}
    <li>{{item.date}} - {{item.title}}</li>
    {% endfor %}
    </ul>
    
      {项集合限制中的项的%3%}
    • {{item.date}-{{item.title}
    • {%endfor%}
总结:

{% assign item-collection = site.item-collection | where_exp:"item","item.featured == true" %}

{% assign item-collection = item-collection | sort: 'date' | reverse %}

<ul>
{% for item in item-collection limit:3 %}
<li>{{item.date}} - {{item.title}}</li>
{% endfor %}
</ul>
{%assign item collection=site.item-collection |其中_exp:“item”,“item.featured==true”%}
{%assign item collection=item collection | sort:'date'| reverse%}
    {项集合限制中的项的%3%}
  • {{item.date}-{{item.title}
  • {%endfor%}

谢谢,这是有道理的,但我不希望在循环遍历集合中的前三项后for循环结束。我想做的是用标签“特色”过滤集合中的所有项目,并输出最多3个按日期排序的“特色”项目。有没有办法做到这一点?我尝试过按“特色”标签对收藏进行分类,但似乎没有任何作用。{%assign item collection=site.item-collection | sort:featured%}{%for item collection%}谢谢
{% assign item-collection = site.item-collection | where_exp:"item","item.featured == true" %}

{% assign item-collection = item-collection | sort: 'date' | reverse %}

<ul>
{% for item in item-collection limit:3 %}
<li>{{item.date}} - {{item.title}}</li>
{% endfor %}
</ul>