You are here

ingredient-formatter.html.twig in Recipe 8.2

Default theme implementation to display an ingredient.

Available variables:

  • ingredient: The ingredient entity.
  • url: A URL to which the ingredient name should be linked. This will typically be the ingredient entity's URL. If the URL value is empty, the name will be printed unlinked.
  • quantity: The ingredient quantity.
  • unit_text: The full name of the ingredient quantity's unit.
  • unit_abbreviation: The abbreviated name of the ingredient quantity's unit.
  • unit_display: A flag that indicates whether to display the full name of the unit or the abbreviation.

@todo Use attributes to set the element classes.

Deprecated

name: The ingredient name. This variable was deprecated in version 8.x-2.0-beta1. It will be removed in version 3.x. It is being deprecated because the entire ingredient entity has been added to the formatter so that other ingredient fields can also be used or printed. Use 'ingredient.label' instead.

  • note: The ingredient note.

See also

template_preprocess_ingredient_formatter()

File

modules/ingredient/templates/ingredient-formatter.html.twig
View source
  1. {#
  2. /**
  3. * @file
  4. * Default theme implementation to display an ingredient.
  5. *
  6. * Available variables:
  7. * - ingredient: The ingredient entity.
  8. * - url: A URL to which the ingredient name should be linked. This will
  9. * typically be the ingredient entity's URL. If the URL value is empty, the
  10. * name will be printed unlinked.
  11. * - quantity: The ingredient quantity.
  12. * - unit_text: The full name of the ingredient quantity's unit.
  13. * - unit_abbreviation: The abbreviated name of the ingredient quantity's unit.
  14. * - unit_display: A flag that indicates whether to display the full
  15. * name of the unit or the abbreviation.
  16. * - @deprecated name: The ingredient name. This variable was deprecated in
  17. * version 8.x-2.0-beta1. It will be removed in version 3.x. It is being
  18. * deprecated because the entire ingredient entity has been added to the
  19. * formatter so that other ingredient fields can also be used or printed.
  20. * Use 'ingredient.label' instead.
  21. * - note: The ingredient note.
  22. *
  23. * @todo Use attributes to set the element classes.
  24. *
  25. * @see template_preprocess_ingredient_formatter()
  26. *
  27. * @ingroup themeable
  28. */
  29. #}
  30. <span class="quantity-unit">{{ quantity|raw }}{% if unit_name %}{% if unit_display %} {{ unit_name }}{% else %} <abbr title="{{ unit_name }}">{{ unit_abbreviation }}</abbr>{% endif %}{% endif %}</span> <span class="ingredient-name">{% if url %}{{ link(ingredient.label, url) }}{% else %}{{ ingredient.label }}{% endif %}{% if note|length > 0 %} ({{ note }}){% endif %}</span>