gpt4 book ai didi

ruby - 不包括在阵列中的液体过滤器?

转载 作者:太空宇宙 更新时间:2023-11-03 16:40:53 25 4
gpt4 key购买 nike

我正在尝试列出所有没有标签“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

最佳答案

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

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

关于ruby - 不包括在阵列中的液体过滤器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52761397/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com