Liquid 是否有 "does not contain" 或 "not in array" 运算符?
Does Liquid have a "does not contain" or "not in array" operator?
在 Liquid 模板中调用数组项时,如何调用 does not contain
或 not in array
?
unless
救援!
创建一个 [A, B, C] 数组。
{% assign input = "A,B,C" | split:"," %}
unless
仅在不满足约束时打印。
这什么都不打印:
{% unless input contains 'A' %}No A{% endunless %}
这会打印“No Z”:
{% unless input contains 'Z' %}No Z{% endunless %}
你可以这样做:
{% if collection.tags contains 'tag' %}
{% else %}
do stuff!
{% endif %}
在 Liquid 模板中调用数组项时,如何调用 does not contain
或 not in array
?
unless
救援!
创建一个 [A, B, C] 数组。
{% assign input = "A,B,C" | split:"," %}
unless
仅在不满足约束时打印。
这什么都不打印:
{% unless input contains 'A' %}No A{% endunless %}
这会打印“No Z”:
{% unless input contains 'Z' %}No Z{% endunless %}
你可以这样做:
{% if collection.tags contains 'tag' %}
{% else %}
do stuff!
{% endif %}