简体   繁体   中英

Multiple conditions in if statement (Liquid)

Is it possible to put multiple conditions inside a single if statement in Shopify Liquid?

For example this is what I have:

 {% if product.type != "A" and product.type != "B" and product.type != "C" %} //do something {% endif %} 

The reason I'm wondering is because syntax highlighting stops after the first "and" operator , as if everything after that has incorrect syntax.

Your syntax is 100% valid and will work in Shopify

{% if product.type != "A" and product.type != "B" and product.type != "C" %}
    //do something
{% endif %}

I guess the editor what you are using has a bug in syntax highlighter for liquid. That's why you confused

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM