Skip to content

Commit dd43d5a

Browse files
linawolfjaapio
authored andcommitted
[TASK] Break up table templates into parts
So that each part can be changed individually
1 parent e402c66 commit dd43d5a

File tree

9 files changed

+70
-67
lines changed

9 files changed

+70
-67
lines changed
Lines changed: 6 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,7 @@
1-
{# Define a variable to store the classes #}
2-
{% set tableClasses = '' %}
3-
4-
{# Check and add classes conditionally #}
5-
{% if tableNode.classes %}
6-
{% set tableClasses = tableClasses ~ tableNode.classesString ~ ' ' %}
7-
{% endif %}
8-
{% if tableNode.hasOption('align') %}
9-
{% set tableClasses = tableClasses ~ 'align-' ~ tableNode.option('align') ~ ' ' %}
10-
{% endif %}
11-
{% if tableNode.hasOption('widths') %}
12-
{% set tableClasses = tableClasses ~ 'colwidths-' ~ tableNode.option('widths') ~ ' ' %}
13-
{% endif %}
14-
{% if tableNode.hasOption('grid') == 'grid' %}
15-
{% set tableClasses = tableClasses ~ 'grid-' ~ tableNode.option('grid') ~ ' ' %}
16-
{% endif %}
17-
18-
{% set tableStyle = '' %}
19-
{% if tableNode.hasOption('width') %}
20-
{% set tableStyle = tableStyle ~ 'width: ' ~ tableNode.option('width') ~ '; ' %}
21-
{% endif %}
22-
23-
<table
24-
{%- if tableClasses|trim %} class="{{ tableClasses|trim }}"{% endif %}
25-
{%- if tableStyle|trim %} style="{{ tableStyle|trim }}"{% endif %}
26-
>
27-
{% if tableNode.hasOption('caption') %}
28-
<caption>{{ tableNode.option('caption') }}</caption>
29-
{% endif %}
30-
{% if tableNode.columnWidth %}
31-
<colgroup>
32-
{% for width in tableNode.columnWidth %}
33-
{% if width<=0 %}
34-
<col style="width: auto">
35-
{% else %}
36-
<col style="width: {{ width }}%">
37-
{% endif %}
38-
{% endfor %}
39-
</colgroup>
40-
{% endif %}
41-
{% if tableHeaderRows is not empty %}
42-
<thead>
43-
{% for tableHeaderRow in tableHeaderRows %}
44-
<tr>
45-
{% for column in tableHeaderRow.columns %}
46-
<th{% if column.colspan > 1 %} colspan="{{ column.colspan }}"{% endif %}>
47-
{%- for child in column.children -%}
48-
{{- renderNode(child) -}}
49-
{% endfor %}</th>
50-
{% endfor %}
51-
</tr>
52-
{% endfor %}
53-
</thead>
54-
{% endif %}
55-
56-
<tbody>
57-
{% for tableRow in tableRows %}
58-
<tr>
59-
{% for column in tableRow.columns %}
60-
<td{% if column.colSpan > 1 %} colspan="{{ column.colSpan }}"{% endif %}{% if column.rowSpan > 1 %} rowspan="{{ column.rowSpan }}"{% endif %}>
61-
{%- for child in column.children -%}
62-
{{- renderNode(child) -}}
63-
{%- else %}&nbsp;{% endfor %}</td>
64-
{% endfor %}
65-
</tr>
66-
{% endfor %}
67-
</tbody>
1+
<table {%- include "body/table/table-classes.html.twig" -%}
2+
{%- include "body/table/table-inline-style.html.twig" -%}>
3+
{% include "body/table/table-caption.html.twig" %}
4+
{% include "body/table/table-colgroups.html.twig" %}
5+
{% include "body/table/table-header.html.twig" %}
6+
{% include "body/table/table-body.html.twig" %}
687
</table>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<tbody>
2+
{% for tableRow in tableRows %}
3+
{% include "body/table/table-row.html.twig" %}
4+
{% endfor %}
5+
</tbody>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{% if tableNode.hasOption('caption') %}
2+
<caption>{{ tableNode.option('caption') }}</caption>
3+
{% endif %}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<td{% if column.colSpan > 1 %} colspan="{{ column.colSpan }}"{% endif %}{% if column.rowSpan > 1 %} rowspan="{{ column.rowSpan }}"{% endif %}>
2+
{%- for child in column.children -%}
3+
{{- renderNode(child) -}}
4+
{%- else %}&nbsp;{% endfor %}</td>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{%- set tableClasses = '' -%}
2+
3+
{# Check and add classes conditionally #}
4+
{%- if tableNode.classes -%}
5+
{%- set tableClasses = tableClasses ~ tableNode.classesString ~ ' ' -%}
6+
{%- endif -%}
7+
{%- if tableNode.hasOption('align') -%}
8+
{%- set tableClasses = tableClasses ~ 'align-' ~ tableNode.option('align') ~ ' ' -%}
9+
{%- endif -%}
10+
{%- if tableNode.hasOption('widths') -%}
11+
{%- set tableClasses = tableClasses ~ 'colwidths-' ~ tableNode.option('widths') ~ ' ' -%}
12+
{%- endif -%}
13+
{%- if tableNode.hasOption('grid') == 'grid' -%}
14+
{%- set tableClasses = tableClasses ~ 'grid-' ~ tableNode.option('grid') ~ ' ' -%}
15+
{%- endif -%}
16+
17+
{%- if tableClasses|trim %} class="{{ tableClasses|trim }}"{% endif -%}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{% if tableNode.columnWidth %}
2+
<colgroup>
3+
{% for width in tableNode.columnWidth %}
4+
{% if width<=0 %}
5+
<col style="width: auto">
6+
{% else %}
7+
<col style="width: {{ width }}%">
8+
{% endif %}
9+
{% endfor %}
10+
</colgroup>
11+
{% endif %}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{% if tableHeaderRows is not empty %}
2+
<thead>
3+
{% for tableHeaderRow in tableHeaderRows %}
4+
<tr>
5+
{% for column in tableHeaderRow.columns %}
6+
<th{% if column.colspan > 1 %} colspan="{{ column.colspan }}"{% endif %}>
7+
{%- for child in column.children -%}
8+
{{- renderNode(child) -}}
9+
{% endfor %}</th>
10+
{% endfor %}
11+
</tr>
12+
{% endfor %}
13+
</thead>
14+
{% endif %}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{%- set tableStyle = '' -%}
2+
{%- if tableNode.hasOption('width') -%}
3+
{%- set tableStyle = tableStyle ~ 'width: ' ~ tableNode.option('width') ~ '; ' -%}
4+
{%- endif -%}
5+
{%- if tableStyle|trim %} style="{{ tableStyle|trim }}"{% endif -%}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<tr>
2+
{% for column in tableRow.columns %}
3+
{% include "body/table/table-cell.html.twig" %}
4+
{% endfor %}
5+
</tr>

0 commit comments

Comments
 (0)