•••
 
Documentation   /   Building templates   /   Repeating sections
 
 

Repeating sections

 

[[REPEAT]] repeats a block once for each value in a list. Use it for schedules, line items, shareholders and anything else with a variable number of rows.

[[REPEAT]]
<p>{{#}}. {{shareholder_name}} holds {{shares}} shares.</p>
[[ENDREPEAT]]

If shareholder_name holds three values, the block appears three times:

1. Ann Jones holds 500 shares.
2. Ben Price holds 300 shares.
3. Cat Wu holds 200 shares.

How it works

  • Inside the block, each {{variable}} that holds a list is replaced with its value for that row: {{shareholder_name:0}}, then {{shareholder_name:1}}, and so on.
  • Variables that aren't lists, such as {{c_entity}}, stay the same on every row.
  • {{#}} gives the row number, starting at 1.
  • The number of rows is the length of the longest list in the block.
  • [[IF]], [[NOT]] and [[ELSEIF]] inside the block test each row's value.

Options

[[REPEAT=count:5]] ... [[ENDREPEAT]]
[[REPEAT=static:true]] ... [[ENDREPEAT]]
Option Effect
count:{number} Always shows this many rows.
static:true Stops recipients adding or removing rows.

Collecting rows in a form

If the fields inside the block have ---collect_data:true, recipients can add and remove rows as they fill in the form.

Lists from elsewhere

A list can come from a multi-select field, from a workflow (pass values separated by [|]) or from a data source (see Pulling data into documents).

[[LOOP]] and [[ENDLOOP]] are alternative names for [[REPEAT]] and [[ENDREPEAT]].