Liquid 包含了大量邏輯(logical)和比較操作符(comparison operator)。
== |
相等 |
!= |
不相等 |
> |
大于 |
< |
小于 |
>= |
大于或等于 |
<= |
小于或等于 |
or |
邏輯或 |
and |
邏輯與 |
例如:
{% if product.title == "Awesome Shoes" %}
These shoes are awesome!
{% endif %}
可以在一個(gè)標(biāo)記(tag)中使用多個(gè)操作符:
{% if product.type == "Shirt" or product.type == "Shoes" %}
This is a shirt or a pair of shoes.
{% endif %}
contains
?用于檢查在一個(gè)字符串中是否存在某個(gè)子串。
{% if product.title contains 'Pack' %}
This product's title contains the word Pack.
{% endif %}
contains
?還可以用于檢查一個(gè)字符串?dāng)?shù)組中是否存在某個(gè)字符串。
{% if product.tags contains 'Hello' %}
This product has been tagged with 'Hello'.
{% endif %}
contains
?只能用于搜索字符串。你不能將其用于從一個(gè)對象數(shù)組中檢查是否存在某個(gè)對象。
? Copyright 2023 深圳藍(lán)曬科技有限公司. 粵ICP備2023054553號-1