farm-2.x-dev/modules/core/quantity/templates/quantity.html.twig
modules/core/quantity/templates/quantity.html.twig
{#
/**
* @file quantity.html.twig
* Default theme implementation to present quantity data.
*
* This template is used when viewing quantity entities.
*
*
* Available variables:
* - quantity: The quantity entity.
* - content: A list of content items. Use 'content' to print all content, or
* - attributes: HTML attributes for the container element.
*
* @see template_preprocess_quantity()
*
* @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) %}
<div{{ attributes.addClass('quantity') }}>
{% if content %}
{{ prefix_fields }}
{% if content.label %}<strong>{{ content.label }}</strong>{% endif %}
{% if content.measure %}({{ content.measure }}){% endif %}
{{ content.value }} {{ content.units }}
{{ suffix_fields }}
{% endif %}
</div>
