annotate core/modules/views/templates/views-view-table.html.twig @ 19:fa3358dc1485 tip

Add ndrum files
author Chris Cannam
date Wed, 28 Aug 2019 13:14:47 +0100
parents 4c8ae668cc8c
children
rev   line source
Chris@0 1 {#
Chris@0 2 /**
Chris@0 3 * @file
Chris@0 4 * Default theme implementation for displaying a view as a table.
Chris@0 5 *
Chris@0 6 * Available variables:
Chris@0 7 * - attributes: Remaining HTML attributes for the element.
Chris@0 8 * - class: HTML classes that can be used to style contextually through CSS.
Chris@0 9 * - title : The title of this group of rows.
Chris@0 10 * - header: The table header columns.
Chris@0 11 * - attributes: Remaining HTML attributes for the element.
Chris@0 12 * - content: HTML classes to apply to each header cell, indexed by
Chris@0 13 * the header's key.
Chris@0 14 * - default_classes: A flag indicating whether default classes should be
Chris@0 15 * used.
Chris@0 16 * - caption_needed: Is the caption tag needed.
Chris@0 17 * - caption: The caption for this table.
Chris@0 18 * - accessibility_description: Extended description for the table details.
Chris@0 19 * - accessibility_summary: Summary for the table details.
Chris@0 20 * - rows: Table row items. Rows are keyed by row number.
Chris@0 21 * - attributes: HTML classes to apply to each row.
Chris@0 22 * - columns: Row column items. Columns are keyed by column number.
Chris@0 23 * - attributes: HTML classes to apply to each column.
Chris@0 24 * - content: The column content.
Chris@0 25 * - default_classes: A flag indicating whether default classes should be
Chris@0 26 * used.
Chris@0 27 * - responsive: A flag indicating whether table is responsive.
Chris@0 28 * - sticky: A flag indicating whether table header is sticky.
Chris@0 29 *
Chris@0 30 * @see template_preprocess_views_view_table()
Chris@0 31 *
Chris@0 32 * @ingroup themeable
Chris@0 33 */
Chris@0 34 #}
Chris@0 35 {%
Chris@0 36 set classes = [
Chris@0 37 'cols-' ~ header|length,
Chris@0 38 responsive ? 'responsive-enabled',
Chris@0 39 sticky ? 'sticky-enabled',
Chris@0 40 ]
Chris@0 41 %}
Chris@0 42 <table{{ attributes.addClass(classes) }}>
Chris@0 43 {% if caption_needed %}
Chris@0 44 <caption>
Chris@0 45 {% if caption %}
Chris@0 46 {{ caption }}
Chris@0 47 {% else %}
Chris@0 48 {{ title }}
Chris@0 49 {% endif %}
Chris@0 50 {% if (summary is not empty) or (description is not empty) %}
Chris@0 51 <details>
Chris@0 52 {% if summary is not empty %}
Chris@0 53 <summary>{{ summary }}</summary>
Chris@0 54 {% endif %}
Chris@0 55 {% if description is not empty %}
Chris@0 56 {{ description }}
Chris@0 57 {% endif %}
Chris@0 58 </details>
Chris@0 59 {% endif %}
Chris@0 60 </caption>
Chris@0 61 {% endif %}
Chris@0 62 {% if header %}
Chris@0 63 <thead>
Chris@0 64 <tr>
Chris@0 65 {% for key, column in header %}
Chris@0 66 {% if column.default_classes %}
Chris@0 67 {%
Chris@0 68 set column_classes = [
Chris@0 69 'views-field',
Chris@0 70 'views-field-' ~ fields[key],
Chris@0 71 ]
Chris@0 72 %}
Chris@0 73 {% endif %}
Chris@0 74 <th{{ column.attributes.addClass(column_classes).setAttribute('scope', 'col') }}>
Chris@0 75 {%- if column.wrapper_element -%}
Chris@0 76 <{{ column.wrapper_element }}>
Chris@0 77 {%- if column.url -%}
Chris@0 78 <a href="{{ column.url }}" title="{{ column.title }}">{{ column.content }}{{ column.sort_indicator }}</a>
Chris@0 79 {%- else -%}
Chris@0 80 {{ column.content }}{{ column.sort_indicator }}
Chris@0 81 {%- endif -%}
Chris@0 82 </{{ column.wrapper_element }}>
Chris@0 83 {%- else -%}
Chris@0 84 {%- if column.url -%}
Chris@0 85 <a href="{{ column.url }}" title="{{ column.title }}">{{ column.content }}{{ column.sort_indicator }}</a>
Chris@0 86 {%- else -%}
Chris@0 87 {{- column.content }}{{ column.sort_indicator }}
Chris@0 88 {%- endif -%}
Chris@0 89 {%- endif -%}
Chris@0 90 </th>
Chris@0 91 {% endfor %}
Chris@0 92 </tr>
Chris@0 93 </thead>
Chris@0 94 {% endif %}
Chris@0 95 <tbody>
Chris@0 96 {% for row in rows %}
Chris@0 97 <tr{{ row.attributes }}>
Chris@0 98 {% for key, column in row.columns %}
Chris@0 99 {% if column.default_classes %}
Chris@0 100 {%
Chris@0 101 set column_classes = [
Chris@0 102 'views-field'
Chris@0 103 ]
Chris@0 104 %}
Chris@0 105 {% for field in column.fields %}
Chris@0 106 {% set column_classes = column_classes|merge(['views-field-' ~ field]) %}
Chris@0 107 {% endfor %}
Chris@0 108 {% endif %}
Chris@0 109 <td{{ column.attributes.addClass(column_classes) }}>
Chris@0 110 {%- if column.wrapper_element -%}
Chris@0 111 <{{ column.wrapper_element }}>
Chris@0 112 {% for content in column.content %}
Chris@0 113 {{ content.separator }}{{ content.field_output }}
Chris@0 114 {% endfor %}
Chris@0 115 </{{ column.wrapper_element }}>
Chris@0 116 {%- else -%}
Chris@0 117 {% for content in column.content %}
Chris@0 118 {{- content.separator }}{{ content.field_output -}}
Chris@0 119 {% endfor %}
Chris@0 120 {%- endif %}
Chris@0 121 </td>
Chris@0 122 {% endfor %}
Chris@0 123 </tr>
Chris@0 124 {% endfor %}
Chris@0 125 </tbody>
Chris@0 126 </table>