【问题标题】:Liquid filter for not included in array?液体过滤器不包含在阵列中?
【发布时间】:2018-10-11 13:33:07
【问题描述】:

我正在尝试列出所有没有标签“app”的页面

这适用于带有标签 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

【问题讨论】:

    标签: ruby jekyll liquid


    【解决方案1】:

    我不相信这是可能的。在这种情况下,我认为您必须遍历页面并在循环中包含 unless 条件。所以像:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-03-15
      • 2018-01-17
      • 2017-07-27
      • 1970-01-01
      • 1970-01-01
      • 2023-03-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多