Skip to content

Commit d53d4b7

Browse files
committed
minor #127 Add a wrapper element for tables (javiereguiluz)
This PR was merged into the main branch. Discussion ---------- Add a wrapper element for tables We need this to make tables responsive ... and not only in small devices. See for example the super wide table in this section: https://symfony.wip/doc/current/mailer.html#using-a-3rd-party-transport Question: is there any way to reuse the original template from doctrine/rst-parser? Our new template is literally `<div class="table-wrapper"> {{ the_old_template }} </div>` so it's sad to duplicate the old template entirely. Thanks! Commits ------- 08654dd Add a wrapper element for tables
2 parents d9e7cb9 + 08654dd commit d53d4b7

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<div class="table-wrapper">
2+
<table{% if tableNode.classes %} class="{{ tableNode.classesString }}"{% endif %}>
3+
{% if tableHeaderRows is not empty %}
4+
<thead>
5+
{% for tableHeaderRow in tableHeaderRows %}
6+
<tr>
7+
{% for column in tableHeaderRow.columns %}
8+
<th{% if column.colspan > 1 %} colspan="{{ column.colspan }}"{% endif %}>{{ column.render|raw }}</th>
9+
{% endfor %}
10+
</tr>
11+
{% endfor %}
12+
</thead>
13+
{% endif %}
14+
<tbody>
15+
{% for tableRow in tableRows %}
16+
<tr>
17+
{% for column in tableRow.columns %}
18+
<td{% if column.colSpan > 1 %} colspan="{{ column.colSpan }}"{% endif %}{% if column.rowSpan > 1 %} rowspan="{{ column.rowSpan }}"{% endif %}>{{ column.render|raw }}</td>
19+
{% endfor %}
20+
</tr>
21+
{% endfor %}
22+
</tbody>
23+
</table>
24+
</div>

tests/fixtures/expected/blocks/nodes/tables.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<p>Simple table with head:</p>
22

3+
<div class="table-wrapper">
34
<table>
45
<thead>
56
<tr>
@@ -21,6 +22,7 @@
2122
</tr>
2223
</tbody>
2324
</table>
25+
</div>
2426

2527
<table>
2628
<thead>
@@ -62,6 +64,7 @@
6264

6365
<p>Simple table headless:</p>
6466

67+
<div class="table-wrapper">
6568
<table>
6669
<tbody>
6770
<tr>
@@ -76,6 +79,7 @@
7679
</tr>
7780
</tbody>
7881
</table>
82+
</div>
7983

8084
<table>
8185
<tbody>
@@ -92,6 +96,7 @@
9296

9397
<p>Grid table:</p>
9498

99+
<div class="table-wrapper">
95100
<table>
96101
<tbody>
97102
<tr>
@@ -109,9 +114,11 @@
109114
</tr>
110115
</tbody>
111116
</table>
117+
</div>
112118

113119
<p>Grid table with head:</p>
114120

121+
<div class="table-wrapper">
115122
<table>
116123
<thead>
117124
<tr>
@@ -131,9 +138,11 @@
131138
</tr>
132139
</tbody>
133140
</table>
141+
</div>
134142

135143
<p>Grid table with head and multi-line cells:</p>
136144

145+
<div class="table-wrapper">
137146
<table>
138147
<thead>
139148
<tr>
@@ -161,3 +170,4 @@
161170
</tr>
162171
</tbody>
163172
</table>
173+
</div>

0 commit comments

Comments
 (0)