annotate core/modules/system/templates/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 to display a table.
Chris@0 5 *
Chris@0 6 * Available variables:
Chris@0 7 * - attributes: HTML attributes to apply to the <table> tag.
Chris@0 8 * - caption: A localized string for the <caption> tag.
Chris@0 9 * - colgroups: Column groups. Each group contains the following properties:
Chris@0 10 * - attributes: HTML attributes to apply to the <col> tag.
Chris@0 11 * Note: Drupal currently supports only one table header row, see
Chris@0 12 * https://www.drupal.org/node/893530 and
Chris@0 13 * http://api.drupal.org/api/drupal/includes!theme.inc/function/theme_table/7#comment-5109.
Chris@0 14 * - header: Table header cells. Each cell contains the following properties:
Chris@0 15 * - tag: The HTML tag name to use; either 'th' or 'td'.
Chris@0 16 * - attributes: HTML attributes to apply to the tag.
Chris@0 17 * - content: A localized string for the title of the column.
Chris@0 18 * - field: Field name (required for column sorting).
Chris@0 19 * - sort: Default sort order for this column ("asc" or "desc").
Chris@0 20 * - sticky: A flag indicating whether to use a "sticky" table header.
Chris@0 21 * - rows: Table rows. Each row contains the following properties:
Chris@0 22 * - attributes: HTML attributes to apply to the <tr> tag.
Chris@0 23 * - data: Table cells.
Chris@0 24 * - no_striping: A flag indicating that the row should receive no
Chris@0 25 * 'even / odd' styling. Defaults to FALSE.
Chris@0 26 * - cells: Table cells of the row. Each cell contains the following keys:
Chris@0 27 * - tag: The HTML tag name to use; either 'th' or 'td'.
Chris@0 28 * - attributes: Any HTML attributes, such as "colspan", to apply to the
Chris@0 29 * table cell.
Chris@0 30 * - content: The string to display in the table cell.
Chris@0 31 * - active_table_sort: A boolean indicating whether the cell is the active
Chris@0 32 table sort.
Chris@0 33 * - footer: Table footer rows, in the same format as the rows variable.
Chris@0 34 * - empty: The message to display in an extra row if table does not have
Chris@0 35 * any rows.
Chris@0 36 * - no_striping: A boolean indicating that the row should receive no striping.
Chris@0 37 * - header_columns: The number of columns in the header.
Chris@0 38 *
Chris@0 39 * @see template_preprocess_table()
Chris@0 40 *
Chris@0 41 * @ingroup themeable
Chris@0 42 */
Chris@0 43 #}
Chris@0 44 <table{{ attributes }}>
Chris@0 45 {% if caption %}
Chris@0 46 <caption>{{ caption }}</caption>
Chris@0 47 {% endif %}
Chris@0 48
Chris@0 49 {% for colgroup in colgroups %}
Chris@0 50 {% if colgroup.cols %}
Chris@0 51 <colgroup{{ colgroup.attributes }}>
Chris@0 52 {% for col in colgroup.cols %}
Chris@0 53 <col{{ col.attributes }} />
Chris@0 54 {% endfor %}
Chris@0 55 </colgroup>
Chris@0 56 {% else %}
Chris@0 57 <colgroup{{ colgroup.attributes }} />
Chris@0 58 {% endif %}
Chris@0 59 {% endfor %}
Chris@0 60
Chris@0 61 {% if header %}
Chris@0 62 <thead>
Chris@0 63 <tr>
Chris@0 64 {% for cell in header %}
Chris@0 65 <{{ cell.tag }}{{ cell.attributes }}>
Chris@0 66 {{- cell.content -}}
Chris@0 67 </{{ cell.tag }}>
Chris@0 68 {% endfor %}
Chris@0 69 </tr>
Chris@0 70 </thead>
Chris@0 71 {% endif %}
Chris@0 72
Chris@0 73 {% if rows %}
Chris@0 74 <tbody>
Chris@0 75 {% for row in rows %}
Chris@0 76 <tr{{ row.attributes }}>
Chris@0 77 {% for cell in row.cells %}
Chris@0 78 <{{ cell.tag }}{{ cell.attributes }}>
Chris@0 79 {{- cell.content -}}
Chris@0 80 </{{ cell.tag }}>
Chris@0 81 {% endfor %}
Chris@0 82 </tr>
Chris@0 83 {% endfor %}
Chris@0 84 </tbody>
Chris@0 85 {% elseif empty %}
Chris@0 86 <tbody>
Chris@0 87 <tr>
Chris@0 88 <td colspan="{{ header_columns }}">{{ empty }}</td>
Chris@0 89 </tr>
Chris@0 90 </tbody>
Chris@0 91 {% endif %}
Chris@0 92 {% if footer %}
Chris@0 93 <tfoot>
Chris@0 94 {% for row in footer %}
Chris@0 95 <tr{{ row.attributes }}>
Chris@0 96 {% for cell in row.cells %}
Chris@0 97 <{{ cell.tag }}{{ cell.attributes }}>
Chris@0 98 {{- cell.content -}}
Chris@0 99 </{{ cell.tag }}>
Chris@0 100 {% endfor %}
Chris@0 101 </tr>
Chris@0 102 {% endfor %}
Chris@0 103 </tfoot>
Chris@0 104 {% endif %}
Chris@0 105 </table>