Collection Variables: Tables

  • Updated

There are two ways to format tables. You can use -w:tr and -w:tc or use collection loops.

-w:tr and -w:tc

This notation allows you to fill in a table by generating additional rows (-w:tr) or columns (-w:tc).

-w:tr example

First Name

Last Name

{-w:tr officers}{firstName}

{lastName}{/}

 

Output

First Name

Last Name

Jessica

Pearson

Harvey

Specter

Louis

Litt

NOTE: If you use -w:tc instead of -w:tr, you will get funky results like the table below.

 

First Name

Last Name

 

Jessica

Pearson

Harvey

Specter

Louis

Litt

 

-w:tc example

First Name

{-w:tc officers}{firstName}{/}

Last Name

{-w:tc officers}{lastName}{/}

Result

First Name

Jessica

Harvey

Louis

Last Name

Pearson

Specter

Litt

NOTE: If you wrap the variables in one -w:tc, you will get funky results like the table below.

Bad Example

First Name

{-w:tc officers}{firstName}

Last Name

{lastName}{/}

Bad Result

First Name

Jessica

 

Last Name

Pearson

Harvey

Last Name

Specter

Louis

Last Name

Litt

 

 

Collection Loops

To create a table using collection loops, you’ll want to put the opening tag in the left-most cell and the closing tag in the right-most cell.

Example

First Name

Last Name

{#officers}{firstName}

{lastName}{/}

Output

First Name

Last Name

Jessica

Pearson

Harvey

Specter

Louis

Litt

 

Nested Loops

When creating tables with nested collections, make sure that the first collection you use is the collection you want the rows to loop through. This collection will serve as the root of all of the variables and nested collections in the table.

In the example below, the officers collection is the root of all the other variables and collections in the table.

 

Name

Address

{#officers}{name}

{#addresses}{street}, {city}, {provinceState} {postalZip}{/}{/}