Get a hash’s key name This is possibly more of a Twig thing, but if I have a hash…

{% set hash = {
    "key": "value"
} %}


How can I output the key name?

{% for value in hash %}
    &lt;span class="{{ key }}"&gt;{{ value }}&lt;/span&gt;
{% endfor %}
There's an example of this in the Twig documentation: https://twig.symfony.com/doc/3.x/tags/for.html#iterating-over-keys-and-values

In your example, it would be:

{% for key, value in hash %}
    &lt;span class="{{ key }}"&gt;{{ value }}&lt;/span&gt;
{% endfor %}