-
Notifications
You must be signed in to change notification settings - Fork 1
Description
Table row iteration with JTwig for loop is currently not implemented. The desired functionality would allow template designers to add a {% for ... %} and {% endfor %}` instructions respectively in the first and last column of a table and ensures that the row(s) are repeated in the loop.
In practice, it means that the JTwig for and endfor instruction code island must be pushed outside the XML table row element.
Here are the current specifications:
FORROW Formula
The FORROW Formula is used to fill tables with the values of list inputs from the Dynamic Lists Field.
{% for row in input.Firstname %}
| {{input.Firstname[loop.index0]}} | {{input.Lastname[loop.index0]}} | {{input.Birthdate[loop.index0]}} |
|---|
{% endfor %}
More details below.
For Loop in Tables (currently in development)
For loops come with an extra variable defined in the context, the loop variable. The loop variable provides a set of useful properties when within a for loop:
| Variable | Description |
|---|---|
| length | Size of the list or map being iterated |
| index | Current iteration count starting in 1 |
| index0 | Current iteration count starting in 0 |
| revindex | Remaining # of iterations to reach the end of the list or map, ends in 1 |
| revindex0 | Remaining # of iterations to reach the end of the list or map, ends in 0 |
| first | Boolean property only true in the first iteration |
| last | Boolean property only true in the last iteration |
| parent | Accessing the parent context |
If you want to replicate rows in a table, try to put a for loop as close as possible to the edge of a row.
| My header | A {% set total=0 %} | B | C {% for item in [1,2,3] %} |
|---|---|---|---|
| {{loop.index0}} | {{loop.index}} | {{item}} | I want to replicate this row{% set total=item+total %} {% endfor %} |
| {{total*1000|number_format(2,'.', ''')}} |
| My header | A | B | C |
|---|---|---|---|
| 0 | 1 | 1 | I want to replicate this row |
| 1 | 2 | 2 | I want to replicate this row |
| 2 | 3 | 3 | I want to replicate this row |
| 6'000.00 |