I notice that you said:
I have a node named "reviews"
I just wanted to make sure that you meant that you have a Content Type with the machine name "reviews", and not a node title or pathname.
Otherwise, the field template named field--node--field_rating--reviews.html.twig
might not even be sourced.
You can test this by printing a debugging statement in your twig template using one of the methods discussed here:
https://www.drupal.org/docs/8/theming/twig/discovering-and-inspecting-variables-in-twig-templates
Make sure that you only use this for local testing, and disable it on production environment.
If the debugging statement prints, then your template is being sourced. You can use dump()
or kint()
to discover and inspect variables until you find the correct one.
If the debugging statement does not print, turn on theme suggestions as shown here:
https://www.drupal.org/node/2358785
You may find that your twig template really needs to have a different name, such as field--node--field_rating--review.html.twig
, or even just field--field_rating.html.twig
.
I mention this because I tried the exact code that you pasted above, and it worked for me in an identically-named twig template, so it's possible that something else is at play.