如何 select Liquid 中的特定项目

How to select specific items in Liquid

假设我有一个标签列表:iFix_6.3iFix_7.0iFix_7.1iFix_8.0announcement 等等......我只想 运行 对某些 几个 标签进行操作。如何检查这些多个值?

contains,但我正在寻找它的反义词和多个值...

这是一个例子,我实际上过滤掉了所有包含 iFix_6.3 标签的帖子,从而显示所有其他帖子。这实际上还行不通......另外需要扩展以适用于多个标签。

// posts with iFix_xxx tag should be filtered from the main posts view.
{% assign postUpdates = site.posts | where_exp:"item", "item.tags != 'iFix_6.3'" %} 
{% for post in postUpdates limit:10 %}
<div class="postItem inline">
    <p class="postDate">{% if post.pinned %}<span class="glyphicon glyphicon-pushpin"></span>{% endif %}{{post.date | date: '%B %d, %Y'}}</p>
    <p class="postTitle"><a href="{{site.baseurl}}{{post.url}}">{{post.title}}</a></p>
</div>
{% endfor %}

您可以通过使用 split 和一串以逗号分隔的标签构建排除标签数组 (excluded_tags) 来实现此目的。然后对于每个 post,您迭代 post 的标签。使用 contains 检查标签是否在 excluded_tags 中,如果是,则使用 unless 控制流标签提升标志 filtered_out 以不显示 post .

{% assign excluded_tags = "iFix_6.2,iFix_6.3,announcement" | split : "," %}

{% for post in site.posts limit:10 %}
   {% assign filtered_out = False %}
   {% for tag in post.tags %}
       {% if excluded_tags contains tag %}
           {% assign filtered_out = True %}
           {% break %}
       {% endif %}
   {% endfor %}

   {% unless filtered_out %}
       ...
   {% endunless %}
{% endfor %}

看来 可以破案。

{% assign postUpdates = site.posts | where_exp:"item", "unless item.tags contains 'iFix_6.3'" %}