巴克励步
发布于:2024-07-07
true。{% if product.title == "Awesome Shoes" %}
These shoes are awesome!
{% endif %}
These shoes are awesome!
if某个条件时才执行代码块。{% unless product.title == "Awesome Shoes" %}
These shoes are not awesome.
{% endunless %}These shoes are not awesome.{% if product.title != "Awesome Shoes" %}
These shoes are not awesome.
{% endif %}if在或块内添加更多条件unless。<!-- If customer.name = "anonymous" -->
{% if customer.name == "kevin" %}
Hey Kevin!
{% elsif customer.name == "anonymous" %}
Hey Anonymous!
{% else %}
Hi Stranger!
{% endif %}Hey Anonymous!case初始化 switch 语句,when语句定义各种条件。when标签可以接受多个值。当提供多个值时,当变量与标签内的任意值匹配时,就会返回表达式。以逗号分隔列表的形式提供值,或使用运算符分隔它们or。else案例末尾的可选语句提供了在没有任何条件满足时执行的代码。{% assign handle = "cake" %}
{% case handle %}
{% when "cake" %}
This is a cake
{% when "cookie", "biscuit" %}
This is a cookie
{% else %}
This is not a cake nor a cookie
{% endcase %}
This is a cake