|
8 | 8 | <h{{ headingLevel }} class="nhsuk-table__heading-tab">{{ params.heading | safe }}</h{{ headingLevel }}> |
9 | 9 | {%- endif %} |
10 | 10 | {%- endif %} |
11 | | - <table {%- if params.responsive %} role="table"{% endif %} class="nhsuk-table{%- if params.responsive %}-responsive{% endif %} |
12 | | - {%- if params.tableClasses %} {{ params.tableClasses }}{% endif %}" |
13 | | - {{- nhsukAttributes(params.attributes) }}> |
| 11 | + <table class="nhsuk-table |
| 12 | + {%- if params.responsive %}-responsive{% endif %} |
| 13 | + {%- if params.tableClasses %} {{ params.tableClasses }}{% endif %}" |
| 14 | + {%- if params.responsive %} role="table"{% endif %} |
| 15 | + {{- nhsukAttributes(params.attributes) }}> |
| 16 | + |
14 | 17 | {%- if params.caption %} |
15 | 18 | <caption class="nhsuk-table__caption |
16 | | - {%- if params.captionClasses %} {{ params.captionClasses }}{% endif %}">{{ params.caption }}</caption> |
| 19 | + {%- if params.captionClasses %} {{ params.captionClasses }}{% endif %}"> |
| 20 | + {{- params.caption -}} |
| 21 | + </caption> |
17 | 22 | {%- endif %} |
| 23 | + |
18 | 24 | {%- if params.head %} |
19 | | - <thead role="rowgroup" class="nhsuk-table__head"> |
20 | | - <tr role="row"> |
21 | | - {%- for item in params.head %} |
22 | | - <th role="columnheader" class=" |
23 | | - {%- if item.format %} nhsuk-table__header--{{ item.format }}{% endif %}" scope="col"> |
24 | | - {{ item.html |safe if item.html else item.text }} |
25 | | - </th> |
26 | | - {%- endfor %} |
27 | | - </tr> |
| 25 | + <thead class="nhsuk-table__head" {%- if params.responsive %} role="rowgroup"{% endif %}> |
| 26 | + <tr {%- if params.responsive %} role="row"{% endif %}> |
| 27 | + {%- for item in params.head %} |
| 28 | + <th scope="col" class="nhsuk-table__header |
| 29 | + {%- if item.format %} nhsuk-table__header--{{ item.format }}{% endif %} |
| 30 | + {%- if item.classes %} {{ item.classes }}{% endif %}" |
| 31 | + {%- if item.colspan %} colspan="{{ item.colspan }}"{% endif %} |
| 32 | + {%- if item.rowspan %} rowspan="{{ item.rowspan }}"{% endif %} |
| 33 | + {%- if params.responsive %} role="columnheader"{% endif %} |
| 34 | + {{- nhsukAttributes(item.attributes) }}> |
| 35 | + {{- item.html | safe if item.html else item.text -}} |
| 36 | + </th> |
| 37 | + {%- endfor %} |
| 38 | + </tr> |
28 | 39 | </thead> |
29 | 40 | {%- endif %} |
30 | 41 | <tbody class="nhsuk-table__body"> |
31 | 42 | {%- for row in params.rows %} |
32 | | - <tr role="row" class="nhsuk-table__row" > |
33 | | - {%- if params.responsive %} |
34 | | - {%- for cell in row %} |
35 | | - <td role="cell" class="nhsuk-table__cell{% if cell.format %} nhsuk-table__cell--{{ cell.format }}{% endif %}"> |
36 | | - <span class="nhsuk-table-responsive__heading" aria-hidden="true">{{cell.header}} </span>{{ cell.html | safe if cell.html else cell.text }} |
| 43 | + <tr class="nhsuk-table__row" {%- if params.responsive %} role="row"{% endif %}> |
| 44 | + {%- for cell in row %} |
| 45 | + {% set commonAttributes %} |
| 46 | + {%- if cell.colspan %} colspan="{{ cell.colspan }}"{% endif %} |
| 47 | + {%- if cell.rowspan %} rowspan="{{ cell.rowspan }}"{% endif %} |
| 48 | + {{- nhsukAttributes(cell.attributes) -}} |
| 49 | + {% endset -%} |
| 50 | + |
| 51 | + {% set commonContents %} |
| 52 | + {%- if params.responsive -%} |
| 53 | + <span class="nhsuk-table-responsive__heading" aria-hidden="true">{{ cell.header }} </span> |
| 54 | + {%- endif -%} |
| 55 | + {{- cell.html | safe if cell.html else cell.text -}} |
| 56 | + {% endset -%} |
| 57 | + |
| 58 | + {%- if loop.first and params.firstCellIsHeader and not params.responsive %} |
| 59 | + <th scope="row" class="nhsuk-table__header |
| 60 | + {%- if cell.classes %} {{ cell.classes }}{% endif %}" |
| 61 | + {{- commonAttributes | safe }}> |
| 62 | + {{- commonContents | safe -}} |
| 63 | + </th> |
| 64 | + {%- else %} |
| 65 | + <td class="nhsuk-table__cell |
| 66 | + {%- if cell.format %} nhsuk-table__cell--{{ cell.format }}{% endif %} |
| 67 | + {%- if cell.classes %} {{ cell.classes }}{% endif %}" |
| 68 | + {%- if params.responsive %} role="cell"{% endif %} |
| 69 | + {{- commonAttributes | safe }}> |
| 70 | + {{- commonContents | safe -}} |
37 | 71 | </td> |
38 | | - {%- endfor %} |
39 | | - {%- else %} |
40 | | - {%- for cell in row %} |
41 | | - {%- if loop.first and params.firstCellIsHeader %} |
42 | | - <th class="nhsuk-table__header" scope="row">{{ cell.html | safe if cell.html else cell.text }}</th> |
43 | | - {%- elseif loop.first %} |
44 | | - <td class="nhsuk-table__cell |
45 | | - {%- if cell.format %} nhsuk-table__cell--{{ cell.format }}{% endif %}" |
46 | | - {%- if cell.colspan %} colspan="{{ cell.colspan }}"{% endif %} |
47 | | - {%- if cell.rowspan %} rowspan="{{ cell.rowspan }}"{% endif %}>{{ cell.html | safe if cell.html else cell.text }}</td> |
48 | | - {%- else %} |
49 | | - <td class="nhsuk-table__cell {% if cell.format %}nhsuk-table__cell--{{ cell.format }}{% endif %}" |
50 | | - {%- if cell.colspan %} colspan="{{ cell.colspan }}"{% endif %} |
51 | | - {%- if cell.rowspan %} rowspan="{{ cell.rowspan }}"{% endif %}>{{ cell.html | safe if cell.html else cell.text }}</td> |
52 | | - {%- endif %} |
53 | | - {%- endfor %} |
54 | | - {%- endif %} |
| 72 | + {%- endif %} |
| 73 | + {%- endfor %} |
55 | 74 | </tr> |
56 | 75 | {%- endfor %} |
57 | 76 | </tbody> |
|
0 commit comments