Basic operators
==: equals!=: does not equal>: greater than<: less than>=: greater than or equal to<=: less than or equal toor: logical orand: logical and
Control flow
if
Executes a block of code only if a certain condition is true.
equal
Input:(判断两个值是否相等)
{% if product.title == "Awesome Shoes" %}
These shoes are awesome!
{% endif %}Output:
These shoes are awesome!exist
Another Example:(判断一个值是否为空)
{%- if page.title -%}
<h1 class="page-heading">{{ page.title }}</h1>
{%- endif -%}contains
contains checks for the presence of a substring inside a string.
{% if product.title contains "Pack" %}
This product's title contains the word Pack.
{% endif %}contains can also check for the presence of a string in an array of strings.
{% if product.tags contains "Hello" %}
This product has been tagged with "Hello".
{% endif %}contains can only search strings. You cannot use it to check for an object in an array of objects.
multi
You can do multiple comparisons in a tag using the and and or operators:
{% if product.type == "Shirt" or product.type == "Shoes" %}
This is a shirt or a pair of shoes.
{% endif %}