I am writing a template for a views field in Drupal 8. How can I access the raw values of a multi-value field in views? I tried this but it doesn't work.
{% for i in 0.. row.field_color['#items']|length - 1 %}
{{ row.field_color[i] }}
{% endfor %}
Since you are using it in views-view-fields--styles.html.twig, it would be {{ fields.field_color.0 }}
or {{ fields.field_color.content|striptags }}
.
Use the entity to get the raw values from the database:
{% for item in row._entity.field_color %}
<p>{{ item.value }}</p>
{% endfor %}
{{ row._entity.entitytype.id }}
{{ row.field_color[i]|raw }}
, check example here.{{ row.field_color[i]|striptags }}