You are here

recipe-total-time.html.twig in Recipe 8.2

Theme for the recipe total time pseudo-field.

Available variables:

  • attributes: HTML attributes for the containing element.
  • label: The label for the field.
  • label_hidden: Whether to show the field label or not.
  • label_display: The display settings for the label.
  • title_attributes: HTML attributes for the title.
  • total_time: The content to be displayed by the pseudo-field.
  • content_attributes: HTML attributes for the content.

File

templates/recipe-total-time.html.twig
View source
  1. {#
  2. /**
  3. * @file
  4. * Theme for the recipe total time pseudo-field.
  5. *
  6. * Available variables:
  7. * - attributes: HTML attributes for the containing element.
  8. * - label: The label for the field.
  9. * - label_hidden: Whether to show the field label or not.
  10. * - label_display: The display settings for the label.
  11. * - title_attributes: HTML attributes for the title.
  12. * - total_time: The content to be displayed by the pseudo-field.
  13. * - content_attributes: HTML attributes for the content.
  14. *
  15. * @see template_preprocess_recipe_total_time()
  16. */
  17. #}
  18. {%
  19. set classes = [
  20. 'field',
  21. 'field--name-recipe-total-time',
  22. 'field--type-integer',
  23. 'field--label-' ~ label_display,
  24. ]
  25. %}
  26. {%
  27. set title_classes = [
  28. 'field__label',
  29. label_display == 'visually_hidden' ? 'visually-hidden',
  30. ]
  31. %}
  32. {% if label_hidden %}
  33. <div{{ content_attributes.addClass(classes, 'field__item') }}>{{ total_time }}</div>
  34. {% else %}
  35. <div{{ attributes.addClass(classes) }}>
  36. <div{{ title_attributes.addClass(title_classes) }}>{{ label }}</div>
  37. <div{{ content_attributes.addClass('field__item') }}>{{ total_time }}</div>
  38. </div>
  39. {% endif %}