Here we have syntax of for/foreach loop in Twig file. Please have a look the syntax..
Suppose we have array with name of 'data', so our for loop for twig will be.
{% for key, value in data %}
{{ key }} | {{ value }}
{% endfor %}
OR
In case we need key with value then our syntax will be..
<ul>
{% for key, value in data %}
{% if key!= ' '%}
<li class="{{ key }}"> {{ value }}</li>
{% endif %}
{% endfor %}
</ul>
OR
In case we just need value without key then our syntax will be..
{% for value in data %}
{{ value }}
{% endfor %}
Note: If have any suggestions or issue regarding 'Loop in twig file drupal 8' then you can ask by comments.
Suppose we have array with name of 'data', so our for loop for twig will be.
{% for key, value in data %}
{{ key }} | {{ value }}
{% endfor %}
OR
In case we need key with value then our syntax will be..
<ul>
{% for key, value in data %}
{% if key!= ' '%}
<li class="{{ key }}"> {{ value }}</li>
{% endif %}
{% endfor %}
</ul>
OR
In case we just need value without key then our syntax will be..
{% for value in data %}
{{ value }}
{% endfor %}
Note: If have any suggestions or issue regarding 'Loop in twig file drupal 8' then you can ask by comments.