---
title: "FlowTemplate"
version: "0.9.0"
url: "https://docs.laminapdf.com/reference/sdk/interfaces/flowtemplate/"
---

# FlowTemplate

Defined in: [packages/sdk/src/builder.ts:342](https://github.com/laudebugs/laminapdf/blob/v0.9.0/packages/sdk/src/builder.ts#L342)

A `laminapdf.document/1` template: a [FlowDocument](/reference/sdk/type-aliases/flowdocument.md), with the same keys, in which a value
can be a placeholder that [Builder.flow](/reference/sdk/classes/builder.md#flow) fills from `options.data`.

- `{ $data: "/invoice/number" }` takes a value from the data, by JSON Pointer.
- `{ $each: "/items", do: … }`, in a list, adds `do` once per item of a list in the data;
inside it, `{ $item: "/name" }` takes a value from the current item.
- `{ $if: "/paid", do: … }`, in a list, adds `do` only when the value is there and isn't
`false` or `null`.

Placeholders nest. `type`, `schema` and `profiles` take none: `profiles` is read before filling,
for `new Builder({ profiles })`.

## Example

```ts
const template: FlowTemplate = {
  schema: "laminapdf.document/1",
  styles: { body: { font: "Helvetica", size: 11 } },
  blocks: [
    { type: "heading", level: 1, text: { $data: "/title" } },
    { $each: "/lines", do: { type: "paragraph", text: { $item: "/text" } } },
  ],
};
const data = { title: "Invoice 42", lines: [{ text: "Paper, 2 reams" }] };
builder.flow(template, { data });
```

## Since

0.2.0

## Extends

- [`Templated`](/reference/sdk/type-aliases/templated.md)\<[`FlowDocument`](/reference/sdk/type-aliases/flowdocument.md)\>
