twig for index

128

twig foreach -

{% for key, value in array %}
  {{ key }}: {{ value }}
{% endfor %}

twig for -

<ul>
    {% for key, user in users %}
        <li>{{ key }}: {{ user.username|e }}</li>
    {% endfor %}
</ul>

twig loop variables -

{% for user in users %}
    {{ loop.index }} - {{ user.username }}
{% endfor %}

twig for index -

<h1>Members</h1>
<ul>
    {% for key, user in users %}
        <li>{{ key }}: {{ user.username|e }}</li>
    {% endfor %}
</ul>

twig for index -

<h1>Members</h1>
<ul>
    {% for key in users|keys %}
        <li>{{ key }}</li>
    {% endfor %}
</ul>

Comments

Submit
0 Comments