Multiple conditions in if statement (Liquid)

会有一股神秘感。 提交于 2020-01-06 05:47:09

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/47019799/multiple-conditions-in-if-statement-liquid

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!