How to do case insensitive string comparison?
In my case , i need to add a class menu_active when topic.title equals page.slug. but,now
so my condition fails
nav_bar.html
{% for topic in landing_pages %}
<li role="presentation">
<a class="{% if topic.title == page.slug %}menu_active{% endif %}" href="/{{topic.slug}}/">{{topic.title}}</a>
</li>
{% endfor %}
Pass the strings through the built-in template tag lower/upper and then compare.
<a class="{% if topic.title|lower == page.slug|lower %}menu_active{% endif %}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With