Skip to main content
2 of 4
added 1 character in body

How to get value from item.content [drupal 8]?

I have a node named "reviews" and a custom field named "field_rating". I created a field template named "field--node--field_rating--reviews.html.twig" I want inside the node to change the color with an if statement. I try to do something like that:

{% for item in items %}
{% if item.content > 5 %}
<div style="background-color:green">{{ item.content}}</div>
{% endif %}
{% endfor %}

but it doesn't work.

Any suggestions?

Drupal Version 8.6.1