Elements
Repeat element
A Repeat takes a list in your data, such as line items, contacts or orders, and prints the blocks inside it once for each item. What you put inside is the pattern for one item: a heading, a paragraph, an image, even a whole table. Three items print three copies; an empty list prints nothing.
Use a Repeat when each item needs its own free-form layout. When every item is one row of the same columns, use a Table instead: it draws a ruled grid with a header row and can total columns and group rows (see Table element).
Changing a template needs the editor role or higher in the hosted product; local mode has no roles.
Add one
Open the Add block popover (Add block at the top of the Outline, or the + that
appears between blocks on the canvas in Flow view) and pick Repeat under Data. It
points at the first list Weft finds — in the hosted app, a saved template's data source first,
otherwise your loaded data — or at record.LineItems when there is none, with one paragraph
inside showing a field of each item.
A Repeat can go anywhere a block can: the document body, inside a Section or Conditional, in a column or grid cell, or inside another Repeat.
To add a block inside it, use the + between its blocks on the canvas, or select one of its blocks and press Add block: the new block lands right after the selected one. You can also drag blocks in through the Outline.
A Repeat draws nothing of its own on the canvas, so select it from its Outline row, which reads Repeat · followed by its list path. Clicking a block in any printed copy selects that one block, and an edit there changes every copy.
Properties
Select the Repeat and open the properties panel with ⌘. (Ctrl+. on Windows) or the panel button at the far right of the app bar (tooltip Show properties panel).
Source
- List path — the list to repeat over, such as
record.LineItems. Suggestions from your loaded data appear as you type. If the path does not lead to a list in the loaded data, the field shows a ⚠ and Weft flags it as This list won't resolve, or This isn't a list when it leads to a single value. - Binding — the name each item goes by inside the Repeat. Left empty, it is
item. Use letters, digits and underscores, not starting with a digit.
Page breaks
- Keep each item together — an item never splits across pages — off by default. When on, each item moves to the next page as a unit instead of breaking part-way through; items still break between each other. An item taller than a page still splits; when Weft estimates that one is, it notes This group is taller than a page — it will still split where it must.
Conditional
Show only when a condition is met hides the whole Repeat when its condition fails. It is checked once, outside the list, so it cannot test each item's fields. See Show only when.
Binding it to data
Inside a Repeat, fields reach the current item through the binding name: in a Repeat over
record.LineItems, the field item.Product prints each item's product. When the sample list has
at least one item, field suggestions inside a Repeat include that item's fields (see Text runs). Paths from the whole record, such
as record.QuoteNumber, still work inside a Repeat.
The item's position is available as index, counting from 0. To print 1, 2, 3, use a formula of
index + 1 (see Formulas).
A Repeat inside a Repeat
For orders that each have line items, put one Repeat inside another; the inner List path can
start from the outer item, such as item.LineItems. Inside the inner Repeat, item means the
inner item.
To reach the outer item from inside, give the outer Repeat its own Binding, such as order.
The inner list path becomes order.LineItems, inner fields keep using item., and
order.Number prints the order number on every line. The outer position becomes orderIndex.
Changing Binding does not rewrite fields that already use the old name. Update them yourself; any that stop resolving are flagged.
How it prints
Items print one after another, with no extra space or line between them beyond the blocks' own spacing; with Keep each item together on, each item also gets a little space above and below it. An empty list, or a path that does not lead to a list, prints nothing at all: no gap, no placeholder. Without Keep each item together, an item can break across a page like any other content.
Good to know
- A Repeat has no background, border or padding of its own. For a card per item, put a styled Section inside it (see Section element).
- To print only some items, put a Conditional inside the Repeat and test the item's fields, such
as
item.Quantity(see Conditional element). - A Repeat always holds at least one block: Weft will not delete or drag out the last one, so delete the Repeat instead. Deleting a Repeat asks you to confirm.
- When the list is empty in your sample data, the canvas shows nothing for the Repeat: select it in the Outline. With the built-in sample data, choose Empty line items under Preview shape in the data pill (the button above the document that names the data you are previewing, such as Full quote) to see that case. The check before export also warns This list will be empty (see Check before export).