簡體   English   中英

陣列中不包含液體過濾器?

[英]Liquid filter for not included in array?

我正在嘗試列出所有沒有標簽“ app”的頁面

這適用於帶有標簽應用程序的項目:

{% assign pages = site.pages | where:"tags",page.list_tag | where_exp:"page", "page.tags contains 'app'" | sort:"order_number" %}

但我不能使用“除非”:

{% assign pages = site.pages | where:"tags",page.list_tag | where_exp:"page", "unless page.tags contains 'app'" | sort:"order_number" %}

我收到此錯誤:

Liquid Exception: Liquid syntax error (line 2): Expected end_of_string but found id in /_layouts/list.html

我不認為這是可能的。 在這種情況下,我認為您必須循環瀏覽頁面,並在循環中包含一個unless條件。 所以像這樣:

{% for page in site.pages %}
    {% unless page.tags contains 'app' %}
        {{ page.title }}
    {% endunless %}
{% endfor %}

暫無
暫無

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

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