You are here

quantity.html.twig in farmOS 2.x

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.

File

modules/core/quantity/templates/quantity.html.twig
View source
  1. {#
  2. /**
  3. * @file quantity.html.twig
  4. * Default theme implementation to present quantity data.
  5. *
  6. * This template is used when viewing quantity entities.
  7. *
  8. *
  9. * Available variables:
  10. * - quantity: The quantity entity.
  11. * - content: A list of content items. Use 'content' to print all content, or
  12. * - attributes: HTML attributes for the container element.
  13. *
  14. * @see template_preprocess_quantity()
  15. *
  16. * @ingroup themeable
  17. */
  18. #}
  19. {# Filter content items into arrays to be rendered before and after the standard quantity fields. #}
  20. {% set custom_fields = content|without('label', 'measure', 'value', 'units') %}
  21. {% set prefix_fields = custom_fields|filter((field) => field['#weight'] and field['#weight'] < 0) %}
  22. {% set suffix_fields = custom_fields|filter((field) => not field['#weight'] or field['#weight'] >= 0) %}
  23. <div{{ attributes.addClass('quantity') }}>
  24. {% if content %}
  25. {{ prefix_fields }}
  26. {% if content.label %}<strong>{{ content.label }}</strong>{% endif %}
  27. {% if content.measure %}({{ content.measure }}){% endif %}
  28. {{ content.value }} {{ content.units }}
  29. {{ suffix_fields }}
  30. {% endif %}
  31. </div>