Tag Loop Case Sensitivity

Excursionist
58 0 8

Hello,

I'm working on a loop displaying tags based on conditions and I'm having a hard time working around the case senstitivity.  The logic is like so:

{% if tag contains 'mosquitos' %}

But the tags that exist aren't necessarily capitalized. How can I say "if tag (converted to lowercase) contains 'mosquitos' "?

I've already tried {{ tag | downcase }} but it's not working.

Cheers 

0 Likes
Astronaut
1890 1 393

You may need to do an intermediate step.

{% for tag in tags %}
  {% assign tag_handle = tag | handle %}
  {% if tag_handle contains 'mosquitos' %}
    ...
  {% endif %}
{% endfor %}

 

0 Likes
Excursionist
58 0 8

That works!  Thank you.  I didn't know that a tag object had a handle.  

Cheers

0 Likes
Excursionist
14 0 4

handle is a filter, tags are not objects. 

0 Likes