Does Liquid have a does not contain or not in array operator?

拟墨画扇 提交于 2019-12-03 11:33:18

问题


When calling items from and array in a Liquid template, how do you call does not contain or not in array?


回答1:


unless to the rescue !

Create an [A, B, C] array.

{% assign input = "A,B,C" | split:"," %}

unless print only if constrain is not met.

This prints nothing:

{% unless input contains 'A' %}No A{% endunless %}

This prints "No Z":

{% unless input contains 'Z' %}No Z{% endunless %}


来源:https://stackoverflow.com/questions/30822160/does-liquid-have-a-does-not-contain-or-not-in-array-operator

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