html - How to add class if single tag? -


i have 4 <li></li>, showed or not.

{% if li == 1 %}{% endif %} 

how add class if 1 (single) <li></li> showed?

if display collection of items can check length of array. example:

{% set elems = ['1','2'] %} {# {% set elems = ['1'] %} #}  {%for elem in elems %}   <li{% if elems|length == 1 %} class="single" {% endif %}>     {{elem}}   </li> {%endfor%} 

here working example

hope help


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -