我想在Liquid中使用带有多个条件的if
语句。类似于:
{% if (include.featured == "true" and product.featured == "true") or (include.featured == "false" and product.featured == "false") %}
多个条件语句似乎不起作用。是我语法错了还是Liquid不能处理这种if语句?
我想在Liquid中使用带有多个条件的if
语句。类似于:
{% if (include.featured == "true" and product.featured == "true") or (include.featured == "false" and product.featured == "false") %}
多个条件语句似乎不起作用。是我语法错了还是Liquid不能处理这种if语句?
另一种简化的方法是将else if语句合并,并且在评估为真时,布尔值不一定需要使用"==":
{% if include.featured and product.featured %}
{% assign test = true %}
{% elsif include.featured == false and product.featured == false %}
{% assign test = false %}
{% endif %}
{% if include.featured == product.featured %}
。 - Devon Parsons