Liquid の演算子について

Liquid は、すべての一般的な論理演算子および比較演算子を使用できます。 これらの演算子は、ifunless などのタグで使用することができます。

基本演算子

== Equals
!= 等しくない
> より大きい
< より小さい
>= 以上である
<= 以下である
or 条件 A または条件 B
and 条件 A および条件 B

が次の値を含む

contains は、文字列内のサブストリングの有無をテストします。

{% if page.title contains 'Product' %}

The title of this page contains the word Product.

{% endif %}

contains は、文字列の配列内の文字列の有無もテストできます。

指定の値で始まる

startswith は、文字列が指定のサブストリングで始まるかどうかをテストします。

{% if page.title startswith 'Profile' %}

This is a profile page.

{% endif %}

指定の値で終わる

endswith は、文字列が指定のサブストリングで終わるかどうかをテストします。

{% if page.title endswith 'Forum' %}

This is a forum page.

{% endif %}

参照