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