drupal/core/modules/system/templates/field.html.twig

43 lines
1.4 KiB
Plaintext
Raw Normal View History

{#
/**
* @file
* Default theme implementation for a field.
*
* To override output, copy the "field.html.twig" from the templates directory
* to your theme's directory and customize it, just like customizing other
* Drupal templates such as page.html.twig or node.html.twig.
*
* For example, for a field named 'body' displayed on the 'article' content
* type, any of the following templates will override this default
* implementation. The first of these templates that exists is used:
* - field--body--article.html.twig
* - field--article.html.twig
* - field--body.html.twig
* - field.html.twig
*
* Available variables:
* - attributes: HTML attributes for the containing element.
* - label_hidden: Whether to show the field label or not.
* - title_attributes: HTML attributes for the title.
* - label: The label for the field.
* - content_attributes: HTML attributes for the content.
* - items: List of all the field items. Each item contains:
* - attributes: List of HTML attributes for each item.
* - content: The field item's content.
*
* @see template_preprocess_field()
*
* @ingroup themeable
*/
#}
<div{{ attributes }}>
{% if not label_hidden %}
<div{{ title_attributes.addClass('field-label') }}>{{ label }}</div>
{% endif %}
<div{{ content_attributes.addClass('field-items') }}>
{% for item in items %}
<div{{ item.attributes.addClass('field-item') }}>{{ item.content }}</div>
{% endfor %}
</div>
</div>