I need to take control over the rendering of a field_admin_tags
field in a node.html.twig
template.
This WORKS:
{{ content.field_admin_tags }}
— Renders everything (label + all field values){{ content.field_admin_tags.0 }}
— Renders only the first value in the field, and no label
PROBLEM: I have no control over the markup surrounding the tags, e.g. <ul><li>...</li></ul>
.
So my idea was to iterate over the render array.
But that DOES NOT work:
{% for tag in content.field_admin_tags %}
{{ tag }}
{% endfor %}
I get: Exception: Object of type Drupal\node\Entity\Node cannot be printed
.
I think I'm iterating over the keys/values of the render array vs the items inside the field (if I print out an "X" in each loop, I get 20 X's while I only have two or three values in this field).
I'd like to iterate over content.field_admin_tags.0
, content.field_admin_tags.1
, etc.
Any idea how to fix this? Thanks.