Liquid bug when using "contains" to check if in array

New Member
1 0 2

Note for Shopify users, never used Jekyll or liquid directly so not sure if this issue exists outside Shopify

Say you created an array


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

And say that you want to check if something from Shopify API is in that array, this won't work


{% if input contains {{ gift_card.product.title }} %}
{% else %}
do stuff!
{% endif %}


And strip filters won't work either, you have to remove the space between the word and the brackets after `contains` so it looks like this


{% if input contains {{gift_card.product.title}} %}
{% else %}
do stuff!
{% endif %}


`{{gift_card.product.title}}`, I spent a good 3 hours to find this bug, I don't know why it happens, there's no actual HTML spaces or anything like that.

You probably figured this out already, since this is old, but you can't use the curly braces inside other curly braces. 

So it needs to be :

{% if input contains gift_card.product.title %}