tablerow
Generates an HTML table. Must be wrapped in opening <table>
and closing </table>
HTML tags. For a full list of attributes available within a tablerow loop, refer to the
INFO
Every tablerow
provides a local variable tablerowloop
.
{% tablerow item in array %}
expression
{% endtablerow %}
2
3
item
: Item of the current array.array
: Array to loop over.expression
: Expression to render.
Example:
Data
{
"products": [
{
"slug": "product-1",
"price": 76
},
{
"slug": "YouCan",
"price": 100
},
{
"slug": "product-2",
"price": 30
},
{
"slug": "product-3",
"price": 124
},
]
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Note: Data is only refereed as a reference for this example and is in no means reflecting real world data.
<table>
{% tablerow product in products %}
{{ product.slug }}
{% endtablerow %}
</table>
2
3
4
5
Output
<table>
<tr class="row1">
<td class="col1">
product-1
</td>
<td class="col2">
YouCan
</td>
<td class="col3">
product-2
</td>
<td class="col4">
product-3
</td>
</tr>
</table>
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Paramaters
cols
Defines how many columns the tables should have.
Example:
Data
{
"products": [
{
"slug": "product-1",
"price": 76
},
{
"slug": "YouCan",
"price": 100
},
{
"slug": "product-2",
"price": 30
},
{
"slug": "product-3",
"price": 124
},
]
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Note: Data is only refereed as a reference for this example and is in no means reflecting real world data.
<table>
{% tablerow product in products cols:2 %}
{{ product.slug }}
{% endtablerow %}
</table>
2
3
4
5
Output
<table>
<tr class="row1">
<td class="col1">
product-1
</td>
<td class="col2">
YouCan
</td>
</tr>
<tr class="row2">
<td class="col1">
product-2
</td>
<td class="col2">
product-3
</td>
</tr>
</table>
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
limit
Exits the tablerow
loop after a specific index.
Example:
Data
{
"products": [
{
"slug": "product-1",
"price": 76
},
{
"slug": "YouCan",
"price": 100
},
{
"slug": "product-2",
"price": 30
},
{
"slug": "product-3",
"price": 124
},
]
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Note: Data is only refereed as a reference for this example and is in no means reflecting real world data.
<table>
{% tablerow product in products cols:2 limit:3 %}
{{ product.slug }}
{% endtablerow %}
</table>
2
3
4
5
Output
<table>
<tr class="row1">
<td class="col1">
product-1
</td>
<td class="col2">
YouCan
</td>
</tr>
<tr class="row2">
<td class="col1">
product-2
</td>
</tr>
</table>
2
3
4
5
6
7
8
9
10
11
12
13
14
15
offset
Starts the tablerow
loop after a specific index.
Example:
Data
{
"products": [
{
"slug": "product-1",
"price": 76
},
{
"slug": "YouCan",
"price": 100
},
{
"slug": "product-2",
"price": 30
},
{
"slug": "product-3",
"price": 124
},
]
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Note: Data is only refereed as a reference for this example and is in no means reflecting real world data.
<table>
{% tablerow product in products cols:2 offset:2 %}
{{ product.slug }}
{% endtablerow %}
</table>
2
3
4
5
Output
<table>
<tr class="row1">
<td class="col1">
product-2
</td>
<td class="col2">
product-3
</td>
</tr>
</table>
2
3
4
5
6
7
8
9
10
range
Defines a range of numbers to loop through. The range can be defined by both literal and variable numbers.
Example:
<table>
{% tablerow i in (1..4) %}
{{ i }}
{% endtablerow %}
</table>
2
3
4
5
Output
<table>
<tr class="row1">
<td class="col1">
1
</td>
<td class="col2">
2
</td>
<td class="col3">
3
</td>
<td class="col3">
4
</td>
</tr>
</table>
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
forloop
object
col
- Type:
number
- Description: The 1-based index of the current column.
col0
- Type:
number
- Description: The 0-based index of the current column.
col_first
- Type:
boolean
- Description: Returns
true
if the current column is the first in the row. Returnsfalse
if not.
col_last
- Type:
boolean
- Description: Returns
true
if the current column is the last in the row. Returnsfalse
if not.
first
- Type:
boolean
- Description: Returns
true
if the current iteration is the first. Returnsfalse
if not.
index
- Type:
number
- Description: The 1-based index of the current iteration.
index0
- Type:
number
- Description: The 0-based index of the current iteration.
last
- Type:
boolean
- Description: Returns true if the current iteration is the last. Returns false if not.
length
- Type:
number
- Description: The total number of iterations in the loop.
rindex
- Type:
number
- Description: The 1-based index of the current iteration, in reverse order.
rindex0
- Type:
number
- Description: The 0-based index of the current iteration, in reverse order.
row
- Type:
number
- Description: The 1-based index of current row.
Example object:
{
"col": 1,
"col0": 0,
"col_first": true,
"col_last": false,
"first": true,
"index": 1,
"index0": 0,
"last": false,
"length": 5,
"rindex": 5,
"rindex0": 4,
"row": 1
}
2
3
4
5
6
7
8
9
10
11
12
13
14