{% set nb = 1 %} {% for item in menu %} {% set nb = nb + 1 %} {% endfor %}