6e02282efd0ba74bcb4e904c8559c1d0b892c766
[yaffs-website] / web / themes / contrib / bootstrap / templates / system / table.html.twig
1 {#
2 /**
3  * @file
4  * Default theme implementation to display a table.
5  *
6  * Available variables:
7  * - attributes: HTML attributes to apply to the <table> tag.
8  * - caption: A localized string for the <caption> tag.
9  * - colgroups: Column groups. Each group contains the following properties:
10  *   - attributes: HTML attributes to apply to the <col> tag.
11  *     Note: Drupal currently supports only one table header row, see
12  *     https://www.drupal.org/node/893530 and
13  *     http://api.drupal.org/api/drupal/includes!theme.inc/function/theme_table/7#comment-5109.
14  * - header: Table header cells. Each cell contains the following properties:
15  *   - tag: The HTML tag name to use; either TH or TD.
16  *   - attributes: HTML attributes to apply to the tag.
17  *   - content: A localized string for the title of the column.
18  *   - field: Field name (required for column sorting).
19  *   - sort: Default sort order for this column ("asc" or "desc").
20  * - sticky: A flag indicating whether to use a "sticky" table header.
21  * - rows: Table rows. Each row contains the following properties:
22  *   - attributes: HTML attributes to apply to the <tr> tag.
23  *   - data: Table cells.
24  *   - no_striping: A flag indicating that the row should receive no
25  *     'even / odd' styling. Defaults to FALSE.
26  *   - cells: Table cells of the row. Each cell contains the following keys:
27  *     - tag: The HTML tag name to use; either TH or TD.
28  *     - attributes: Any HTML attributes, such as "colspan", to apply to the
29  *       table cell.
30  *     - content: The string to display in the table cell.
31  *     - active_table_sort: A boolean indicating whether the cell is the active
32  *       table sort.
33  * - footer: Table footer rows, in the same format as the rows variable.
34  * - empty: The message to display in an extra row if table does not have
35  *   any rows.
36  * - header_columns: The number of columns in the header.
37  * - bordered: Flag indicating whether or not the table should be bordered.
38  * - condensed: Flag indicating whether or not the table should be condensed.
39  * - hover: Flag indicating whether or not table rows should be hoverable.
40  * - striped: Flag indicating whether or not table rows should be striped.
41  * - responsive: Flag indicating whether or not the table should be wrapped to
42  *   be responsive (using the Bootstrap Framework .table-responsive wrapper).
43  *
44  * @ingroup templates
45  *
46  * @see template_preprocess_table()
47  */
48 #}
49 {% if responsive %}
50   <div class="table-responsive">
51 {% endif %}
52 {%
53   set classes = [
54     'table',
55     bordered ? 'table-bordered',
56     condensed ? 'table-condensed',
57     hover ? 'table-hover',
58     striped ? 'table-striped',
59     sticky ? 'sticky-enabled',
60   ]
61 %}
62 <table{{ attributes.addClass(classes) }}>
63   {% if caption %}
64     <caption>{{ caption }}</caption>
65   {% endif %}
66
67   {% for colgroup in colgroups %}
68     {% if colgroup.cols %}
69       <colgroup{{ colgroup.attributes }}>
70         {% for col in colgroup.cols %}
71           <col{{ col.attributes }} />
72         {% endfor %}
73       </colgroup>
74     {% else %}
75       <colgroup{{ colgroup.attributes }} />
76     {% endif %}
77   {% endfor %}
78
79   {% if header %}
80     <thead>
81       <tr>
82         {% for cell in header %}
83         {%
84         set cell_classes = [
85           cell.active_table_sort ? 'active',
86         ]
87         %}
88         <{{ cell.tag }}{{ cell.attributes.addClass(cell_classes) }}>
89         {{- cell.content -}}
90       </{{ cell.tag }}>
91       {% endfor %}
92       </tr>
93     </thead>
94   {% endif %}
95
96   {% if rows %}
97     <tbody>
98       {% for row in rows %}
99         {% set row_classes = [cycle(['odd', 'even'], loop.index0)] %}
100         <tr{{ row.attributes.addClass(row_classes) }}>
101           {% for cell in row.cells %}
102             <{{ cell.tag }}{{ cell.attributes }}>
103               {{- cell.content -}}
104             </{{ cell.tag }}>
105           {% endfor %}
106         </tr>
107       {% endfor %}
108     </tbody>
109   {% elseif empty %}
110     <tbody>
111       <tr class="odd">
112         <td colspan="{{ header_columns }}" class="empty message">{{ empty }}</td>
113       </tr>
114     </tbody>
115   {% endif %}
116   {% if footer %}
117     <tfoot>
118       {% for row in footer %}
119         <tr{{ row.attributes }}>
120           {% for cell in row.cells %}
121             <{{ cell.tag }}{{ cell.attributes }}>
122               {{- cell.content -}}
123             </{{ cell.tag }}>
124           {% endfor %}
125         </tr>
126       {% endfor %}
127     </tfoot>
128   {% endif %}
129 </table>
130 {% if responsive %}
131   </div>
132 {% endif %}