stencilproject/Stencil

Support {% if item in list %}

kdawgwilk opened this issue · 4 comments

I have been wishing I could do something list the following in Stencil templates

{% if item in list%}
// Do stuff here now that we know this is in the list
{% endif %}

I initially brought this up over in Sourcery krzysztofzablocki/Sourcery#415

Couldn't you just do {% if list|contains:item %}? Or does that contains filter not work with arrays but only strings?

I have not tried this but I will give it a go

@AliSoftware @kdawgwilk according to StencilSwiftKit code it looks like it is indeed defined only on strings