annotate core/modules/system/templates/field.html.twig @ 19:fa3358dc1485 tip

Add ndrum files
author Chris Cannam
date Wed, 28 Aug 2019 13:14:47 +0100
parents 129ea1e6d783
children
rev   line source
Chris@0 1 {#
Chris@0 2 /**
Chris@0 3 * @file
Chris@0 4 * Default theme implementation for a field.
Chris@0 5 *
Chris@0 6 * To override output, copy the "field.html.twig" from the templates directory
Chris@0 7 * to your theme's directory and customize it, just like customizing other
Chris@0 8 * Drupal templates such as page.html.twig or node.html.twig.
Chris@0 9 *
Chris@0 10 * Instead of overriding the theming for all fields, you can also just override
Chris@0 11 * theming for a subset of fields using
Chris@0 12 * @link themeable Theme hook suggestions. @endlink For example,
Chris@0 13 * here are some theme hook suggestions that can be used for a field_foo field
Chris@0 14 * on an article node type:
Chris@0 15 * - field--node--field-foo--article.html.twig
Chris@0 16 * - field--node--field-foo.html.twig
Chris@0 17 * - field--node--article.html.twig
Chris@0 18 * - field--field-foo.html.twig
Chris@0 19 * - field--text-with-summary.html.twig
Chris@0 20 * - field.html.twig
Chris@0 21 *
Chris@0 22 * Available variables:
Chris@0 23 * - attributes: HTML attributes for the containing element.
Chris@0 24 * - label_hidden: Whether to show the field label or not.
Chris@0 25 * - title_attributes: HTML attributes for the title.
Chris@0 26 * - label: The label for the field.
Chris@0 27 * - multiple: TRUE if a field can contain multiple items.
Chris@0 28 * - items: List of all the field items. Each item contains:
Chris@0 29 * - attributes: List of HTML attributes for each item.
Chris@0 30 * - content: The field item's content.
Chris@0 31 * - entity_type: The entity type to which the field belongs.
Chris@0 32 * - field_name: The name of the field.
Chris@0 33 * - field_type: The type of the field.
Chris@0 34 * - label_display: The display settings for the label.
Chris@0 35 *
Chris@0 36 * @see template_preprocess_field()
Chris@0 37 *
Chris@0 38 * @ingroup themeable
Chris@0 39 */
Chris@0 40 #}
Chris@17 41 {%
Chris@17 42 set title_classes = [
Chris@17 43 label_display == 'visually_hidden' ? 'visually-hidden',
Chris@17 44 ]
Chris@17 45 %}
Chris@0 46
Chris@0 47 {% if label_hidden %}
Chris@0 48 {% if multiple %}
Chris@0 49 <div{{ attributes }}>
Chris@0 50 {% for item in items %}
Chris@0 51 <div{{ item.attributes }}>{{ item.content }}</div>
Chris@0 52 {% endfor %}
Chris@0 53 </div>
Chris@0 54 {% else %}
Chris@0 55 {% for item in items %}
Chris@0 56 <div{{ attributes }}>{{ item.content }}</div>
Chris@0 57 {% endfor %}
Chris@0 58 {% endif %}
Chris@0 59 {% else %}
Chris@0 60 <div{{ attributes }}>
Chris@17 61 <div{{ title_attributes.addClass(title_classes) }}>{{ label }}</div>
Chris@0 62 {% if multiple %}
Chris@0 63 <div>
Chris@0 64 {% endif %}
Chris@0 65 {% for item in items %}
Chris@0 66 <div{{ item.attributes }}>{{ item.content }}</div>
Chris@0 67 {% endfor %}
Chris@0 68 {% if multiple %}
Chris@0 69 </div>
Chris@0 70 {% endif %}
Chris@0 71 </div>
Chris@0 72 {% endif %}