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()
1 theme call to ingredient-formatter.html.twig
- IngredientFormatter::viewElements in modules/
ingredient/ src/ Plugin/ Field/ FieldFormatter/ IngredientFormatter.php - Builds a renderable array for a field value.
File
modules/ingredient/templates/ingredient-formatter.html.twigView source
- {#
- /**
- * @file
- * 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.
- * - @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.
- *
- * @todo Use attributes to set the element classes.
- *
- * @see template_preprocess_ingredient_formatter()
- *
- * @ingroup themeable
- */
- #}
- <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>