Edit in GitHubLog an issue

Table Tag with Markers

Use Table markers to insert table tags in a document

There are two constructs introduced to insert tables inside a document called Table Markers. Table Markers will be used to create the table tags inside the document.

  • table-start {% table-start ARRAY_FIELD %}
  • table-end {% table-end %}

How to use

  • In the table row that needs to be dynamically expanded, place the table-start marker in the first cell and the table-end marker in the last cell of the row.
  • The table-start marker requires an array field (ARRAY_FIELD), which will be used to create the rows/columns in the table depending on the orientation of the table.
  • The content between these markers is then dynamically populated by iterating over the array of objects corresponding to the tag(ARRAY_FIELD) specified in the table-start marker.

JSON representation of the input data:

Copied to your clipboard
1{
2 "school": [
3 {
4 "name": "ABC Public School",
5 "strength": "128",
6 "address": "New Delhi"
7 },
8 {
9 "name": "DEF Public School",
10 "strength": "83",
11 "address": "Hyderabad"
12 },
13 {
14 "name": "XYZ Public School",
15 "strength": "165",
16 "address": "Mumbai"
17 }
18 ]
19}
20

Table created with table start and end constructs

In the above example, school serves as the ARRAY_FIELD over whose data the table is populated. A new row is created for each school, and data is filled in accordingly.

Nested Tables

Table tags with markers can also be used inside another table to create nested tables.

JSON representation of the input data:

Copied to your clipboard
1{
2 "board" : "CBSE",
3 "school": [
4 {
5
6 "name": "ABC Public School",
7 "details": {
8 "contact" : "9XXXXXXXX8",
9 "address": "New Delhi",
10 "sportsAvailable": "No"
11 },
12 "class": [
13 {
14 "name" : "XI",
15 "strength": 65
16 },
17 {
18 "name" : "XII",
19 "strength": 40
20 }
21 ]
22 },
23 {
24 "name": "XYZ Public School",
25 "details": {
26 "contact" : "7XXXXXXXX5",
27 "address": "Mumbai",
28 "sportsAvailable": "Yes"
29 },
30 "class": [
31 {
32 "name" : "X",
33 "strength": 45
34 },
35 {
36 "name" : "XI",
37 "strength": 38
38 },
39 {
40 "name" : "XII",
41 "strength": 82
42 }
43 ]
44 }
45 ]
46}
47

Nested tables with table markers

Create both tables with their respective table markers. In the above example, the school tag acts as the array upon which the outer table is expanded. For each school, the inner table is expanded on its respective class tag, which is mentioned as the array field in the inner table marker.

If you need to use data present in one of the outer tables, mention the context in which the data is present using eval construct along with the tag. In the above example the contact tag is present in school but is needed to be populated in the class table, so we add the school tag in the eval construct of the tag.

Similarly, if a condition needs to be evaluated on data outside the current table, add the context for the same using the eval construct.

Table Markers With different context

  • In the above example, we've used the eval construct with the board tag. As specified earlier, $ indicates that the context is input json itself. So, as mentioned in the input json, the tag will be replaced by its value CBSE.

  • We've also used the eval construct with conditions. In the above examples, both the conditions indicated have school as context. So, the conditional expressions are evaluated in the context of the corresponding school.

Table Markers with different context output

Complex Table Constructs with Table markers

Complex table constructs can also be used along with table markers(table-start, table-end). Below are the examples depicting their usage.

Dynamically expand table rows or columns

Specify the cell extension property in any tag inside the table cell to indicate whether to expand table rows vertically or columns horizontally.

Copied to your clipboard
1{
2 "subscriptions": [
3 {
4 "name": "Adobe Document API",
5 "price": "99"
6 },
7 {
8 "name": "Adobe Marketing API",
9 "price": "199"
10 },
11 {
12 "name": "Adobe Design API",
13 "price": "299"
14 }
15
16 ]
17}
  • Repeat table rows vertically with table markers - To use vertical extension with table markers, add cell-extension(vertical) to a tag.

Vertical extension with table markers

  • Repeat table columns horizontally with table markers - To use horizontal extension with table markers, add cell-extension(horizontal) to a tag and place the table start and end markers at the beginning and end of the column instead of the row.

Horizontal extension with table markers

Dynamic table columns

Discard a column or set of columns in a table from the final generated document using table markers.

Discard column if empty

Columns in a table can be discarded if every element of an array in the input json is empty or null.

How to use
Add a discard-if-empty construct with a boolean false/true along with the template tag to activate discard if empty feature for the corresponding column.

JSON representation of the input data:

Copied to your clipboard
1{
2 "project": [
3 {
4 "name": "ABC Infra",
5 "milestone": "First Milestone",
6 "dateComplete": "24/06/2021",
7 "notes": ""
8 },
9 {
10 "name": "ABC Infra",
11 "milestone": "Second Milestone",
12 "dateComplete": "24/06/2022",
13 "notes": ""
14 },
15 {
16 "name": "DEF Computer Labs",
17 "milestone": "First Milestone",
18 "dateComplete": "12/12/2021",
19 "notes": ""
20 },
21 {
22 "name": "DEF Computer Labs",
23 "milestone": "Second Milestone",
24 "dateComplete": "12/12/2021",
25 "notes": ""
26 }
27 ]
28}

Discard if empty with table markers

Discard column if the condition evaluates to true

Column in a table can be discarded if the condition provided in the discard-if(expr(condition)) evaluates to true for any entry in the array of objects.

How to use
Add discard-if(expr(condition)) construct along with the template tag to activate the discard-if feature for the corresponding column.

Note: discard-if construct can also take a context input as discard-if(expr(condition), context_tag). In this case the condition will be evaluated in the context of context_tag.

JSON representation of the input data:

Copied to your clipboard
1{
2 "conversion": [
3 {
4 "month": "July, 2021",
5 "rate": 10,
6 "method": "Payout by Cheque"
7 },
8 {
9 "month": "September, 2021",
10 "rate": 30,
11 "method": "Payout by Cheque"
12 },
13 {
14 "month": "Dec, 2021",
15 "rate": 20,
16 "method": "Payout by Cheque"
17 },
18 {
19 "month": "April, 2022",
20 "rate": 20,
21 "method": "Payout by Cheque"
22 },
23 {
24 "month": "Dec, 2022",
25 "rate": 30,
26 "method": "Payout by Cheque"
27 }
28 ]
29}

Discard if with table markers

In the above example, we've used discard-if along with context $($ here indicates that the context is the input json itself). So, in this case, the conditions will be evaluated in the context of input json.

Dynamic table rows

Discard a row or set of rows in a table from the final generated document.

Discard the row if the condition evaluates to true

A row in the table can be discarded only when the condition in the discard-row-if(expr(condition)) evaluates to true in the provided context. Add this construct along with the template tag to discard the row based on the provided condition.

For Example: {{PROPERTY:discard-row-if(expr(condition))}}

Note: We can also use context in a similar way to discard-if, as {{PROPERTY:discard-row-if(expr(condition),context_tag)}}.

JSON representation of the input data:

Copied to your clipboard
1{
2 "conversion": [
3 {
4 "month": "July, 2021",
5 "rate": 10,
6 "method": "Payout by Cheque"
7 },
8 {
9 "month": "Dec, 2021",
10 "rate": 20,
11 "method": "Payout by Cheque"
12 },
13 {
14 "month": "Dec, 2022",
15 "rate": 40,
16 "method": "Payout by Cheque"
17 },
18 {
19 "month": "Dec, 2021",
20 "rate": 80,
21 "method": "Payout by Cheque"
22 },
23 {
24 "month": "April, 2022",
25 "rate": 100,
26 "method": "Payout by Cash"
27 },
28 {
29 "month": "Dec, 2022",
30 "rate": 45,
31 "method": "Payout by Cheque"
32 }
33 ]
34}

Discard row if with table markers

  • Privacy
  • Terms of Use
  • Do not sell or share my personal information
  • AdChoices
Copyright © 2024 Adobe. All rights reserved.