-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
{# | ||
Copyright 2024 Scape Agency BV | ||
#} | ||
|
||
{# | ||
Table (<table>) | ||
=========================================================================== | ||
Defines a table. | ||
Variables: | ||
- `table_id`: The id attribute for the <table> element. Defaults to "default-table-id". | ||
- `table_class`: The class attribute for the <table> element. Defaults to "default-table-class". | ||
- `table_headers`: A list of headers for the table, each represented as a string. Defaults to ["Header 1", "Header 2", "Header 3"]. | ||
- `table_rows`: A list of rows for the table, each row represented as a list of cells. Defaults to [["Row 1 Cell 1", "Row 1 Cell 2", "Row 1 Cell 3"], ["Row 2 Cell 1", "Row 2 Cell 2", "Row 2 Cell 3"]]. | ||
Notes: | ||
- The `| e` filter is used to escape any special characters in the variables to prevent XSS attacks. | ||
- The <table> element is used to create tables in an HTML document. | ||
Links: | ||
- https://developer.mozilla.org/en-US/docs/Web/HTML/Element/table | ||
- https://www.w3schools.com/tags/tag_table.asp | ||
#} | ||
|
||
<table id="{{ table_id | default('default-table-id') | e }}" class="{{ table_class | default('default-table-class') | e }}"> | ||
<thead> | ||
<tr> | ||
{% for header in table_headers | default(['Header 1', 'Header 2', 'Header 3']) %} | ||
<th>{{ header | e }}</th> | ||
{% endfor %} | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{% for row in table_rows | default([['Row 1 Cell 1', 'Row 1 Cell 2', 'Row 1 Cell 3'], ['Row 2 Cell 1', 'Row 2 Cell 2', 'Row 2 Cell 3']]) %} | ||
<tr> | ||
{% for cell in row %} | ||
<td>{{ cell | e }}</td> | ||
{% endfor %} | ||
</tr> | ||
{% endfor %} | ||
</tbody> | ||
</table> | ||
|
||
|
||
<!-- Tables --> | ||
<table> | ||
<tr> | ||
{% for header in table_headers %} | ||
<th>{{ header }}</th> | ||
{% endfor %} | ||
</tr> | ||
{% for row in table_rows %} | ||
<tr> | ||
{% for cell in row %} | ||
<td>{{ cell }}</td> | ||
{% endfor %} | ||
</tr> | ||
{% endfor %} | ||
</table> |