Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for table row iteration #7

Open
emeka opened this issue Mar 17, 2020 · 0 comments
Open

Add support for table row iteration #7

emeka opened this issue Mar 17, 2020 · 0 comments
Labels
enhancement New feature or request

Comments

@emeka
Copy link
Contributor

emeka commented Mar 17, 2020

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
@emeka emeka added the enhancement New feature or request label Mar 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant