I use a computed field, to calculate and store a floating value for a node. Now I want to work with this value in a twig template. When I access the field value via {{ content.computed_field.0 }}
it outputs the correct value, say 0.22
. When I try to calculate with this value, i.e. {% set newvalue = content.computed_field.0 * 100 %}
the page breaks (just pre-calculation twig content is outputted).
My first guess was that, for some reason, the field value is stored or read as a string (or another type?!). My DB says its a float and I don't know how to check a variable type in twig.
I tried to to use twigs number_format()
-function : {{ content.computed_field.0|number_format(2) }}
. This transforms the computed field to 1. I have no clue why this happens.
What am I doing wrong? Any tips or a workaround?
I use Drupal 8, Twig 1.25, and Computed Field 8.x-2.0-alpha3
Thank you in advance