I have a Drupal 8 site with a node type exposing a "difficulty level" field which is an integer choosen from a list (1 to 5). Current onsite display is : "difficulty: 3". I would like to replace the value "3" by three black stars and two white ones to picture "3/5" (done via CSS background images).
In field--field-difficulty.html.twig I have replaced item.content by:
{% for i in range(1, 5) %}
{% if (loop.index <= item.content) %}
<span class="active">*</span>
{% else %}
<span class="active"> </span>
{% endif %}
{% endfor %}
But this keep giving me five * displayed, just like if the {% if %} statement was always true. Can someone give me a hint on this please ?