diff --git a/modules/core/quantity/templates/quantity.html.twig b/modules/core/quantity/templates/quantity.html.twig index 0bb9293c..294f0a41 100644 --- a/modules/core/quantity/templates/quantity.html.twig +++ b/modules/core/quantity/templates/quantity.html.twig @@ -16,11 +16,18 @@ * @ingroup themeable */ #} + +{# Filter content items into arrays to be rendered before and after the standard quantity fields. #} +{% set custom_fields = content|without('label', 'measure', 'value', 'units') %} +{% set prefix_fields = custom_fields|filter((field) => field['#weight'] and field['#weight'] < 0) %} +{% set suffix_fields = custom_fields|filter((field) => not field['#weight'] or field['#weight'] >= 0) %} + {% if content %} + {{ prefix_fields }} {% if content.label %}{{ content.label }}{% endif %} {% if content.measure %}({{ content.measure }}){% endif %} {{ content.value }} {{ content.units }} - {{ content|without('label', 'measure', 'value', 'units') }} + {{ suffix_fields }} {% endif %}