Template strings
The syntax Druckling templates use to insert data, format numbers, amounts and dates with filters, and style text.
Most texts in a template are template strings: paragraphs, headings, table cells and totals, barcode values and signer names. A template string is literal text with {{bindings}} that insert data, filters that format it, and a few formatting marks.
Hello **{{customer.name}}**, your total is {{totals.amount | money}}.
Due {{invoice.due_date | date:"[day].[month].[year]"}} · [Pay online](https://pay.example.com)With the invoice-standard sample data, this prints "Hello Northwind Ltd., your total is $10,692.00." on the first line and "Due 22.11.2026 · Pay online" on the second, with "Pay online" as a link.
Bindings
{{path}} inserts the value at a dotted path of the payload. Spaces inside the braces are fine: {{ customer.name }} works too.
- A path is made of names with letters, digits and underscores, separated by dots. A name can't start with a digit, so a binding can't index into a list; print list items with a table.
- Every binding must point to a declared variable. Otherwise the editor shows an error and you can't publish.
- In a table cell, bind the row through the table's row alias, for example
{{item.qty}}.
Data is always inserted as plain text:
| Value in the payload | Prints as |
|---|---|
"Northwind Ltd." | Northwind Ltd. |
4800, 4800.5 | 4800, 4800.5 (use a filter to format numbers) |
true, false | true, false |
["a", "b"] | a, b |
| an object | nothing (bind one of its fields) |
a string with a line break ("12 Pier St\nLeeds") | two lines |
Missing values
A missing key or null prints nothing, with or without a filter, and doesn't fail the render. If the variable is required, the request fails validation before anything renders. To print a fallback, use the default filter.
Filters
A filter formats the bound value: {{path | filter}}, or {{path | filter:"argument"}} for filters that take an argument. The quotes around the argument are optional.
Each binding takes at most one filter. Chaining, as in {{name | upper | default:"n/a"}}, is a validation error, and so is an unknown filter name.
| Filter | Argument | What it does |
|---|---|---|
money | Currency code, such as "EUR" (default: the template's currency) | Formats a number as an amount with a currency symbol. |
date | Date pattern (default: depends on the language) | Formats a YYYY-MM-DD date. |
number | Decimals: "2" or a range such as "0-2" (default: 0) | Formats a number with grouping and decimals. |
percent | Decimals (default: 0) | Multiplies by 100 and adds %. |
upper | Converts to uppercase. | |
lower | Converts to lowercase. | |
default | Fallback text | Prints the fallback when the value is missing, null or empty. |
Filters that expect a number also accept numeric strings such as "12.50". A value they can't format prints unchanged, so {{status | money}} with "n/a" prints n/a.
The examples below were produced by the rendering engine. Unless a row says otherwise, the language is English (en) and the template's currency is USD. "nbsp" stands for a no-break space and "nnbsp" for a narrow no-break space.
money
Prints two decimals (none for JPY and KRW), the language's separators and the currency's symbol.
| Template string | Value | Language, currency | Output |
|---|---|---|---|
{{amount | money}} | 4800 | en, USD | $4,800.00 |
{{amount | money}} | -12.5 | en, USD | -$12.50 |
{{amount | money:"EUR"}} | 4800 | en | €4,800.00 |
{{amount | money:"GBP"}} | 4800 | en | £4,800.00 |
{{amount | money:"CHF"}} | 4800 | en | CHF 4,800.00 (nbsp) |
{{amount | money:"JPY"}} | 4800 | en | ¥4,800 |
{{amount | money}} | 4800 | de, EUR | 4.800,00 € (nbsp) |
{{amount | money}} | 4800 | fr, EUR | 4 800,00 € (nnbsp, nbsp) |
{{amount | money:"PLN"}} | 1234.567 | pl | 1.234,57 zł (nbsp) |
{{amount | money:"XYZ"}} | 4800 | en | XYZ 4,800.00 (nbsp) |
- Without an argument,
moneyuses the currency set in the editor under Document › Output › Currency (USD by default). In an e-invoice template it uses the payload'sinvoice.currency. - Languages with a decimal comma put the symbol after the amount; the others put it before.
- Symbols are built in for USD ($), EUR (€), GBP (£), JPY and CNY (¥), INR (₹), KRW (₩), CAD (CA$), AUD (A$), NZD (NZ$), BRL (R$), MXN (MX$), CHF (CHF), SEK, NOK and DKK (kr), PLN (zł), CZK (Kč), TRY (₺) and ZAR (R). Any other code prints as is, so write codes in uppercase.
date
Formats a value that starts with YYYY-MM-DD. Anything after the date, such as a time, is ignored.
| Template string | Value | Language | Output |
|---|---|---|---|
{{due | date}} | "2026-11-22" | en | Nov 22, 2026 |
{{due | date}} | "2026-11-22" | de, pl and most others | 22.11.2026 |
{{due | date}} | "2026-11-22" | fr, es, it, pt | 22/11/2026 |
{{due | date}} | "2026-11-22" | nl | 22-11-2026 |
{{due | date}} | "2026-11-22T14:30:00Z" | en | Nov 22, 2026 |
{{due | date:"[day].[month].[year]"}} | "2026-11-22" | any | 22.11.2026 |
{{due | date:"[month repr:long] [day], [year]"}} | "2026-11-22" | any | November 22, 2026 |
{{due | date:"[weekday], [day padding:none] [month repr:short] [year]"}} | "2026-11-22" | any | Sunday, 22 Nov 2026 |
{{due | date:"[day padding:none]. [month padding:none]. [year]"}} | "2026-03-05" | any | 5. 3. 2026 |
{{due | date:"[year repr:last_two]"}} | "2026-11-22" | any | 26 |
{{due | date}} | "soon" | any | soon |
Patterns use Typst's date format syntax: components such as [day], [month], [year] and [weekday] in square brackets, with modifiers such as padding:none or repr:long. Text outside the brackets prints as written.
- Month and weekday names are always English, whatever the render language:
[month repr:long]printsNovemberin a German document too. For other languages, use numeric patterns or the default. - An unknown component, such as
[foo], makes the render fail withrender_failed. Publishing renders the sample data, so it catches this as long as the sample data has a date in that field.
Send real calendar dates
The schema only checks that a date starts with YYYY-MM-DD. A value such as 2026-02-31 passes validation, but formatting it with date fails the render with render_failed ("date is invalid"). Validate dates in your own code before you send them.
number
| Template string | Value | Language | Output |
|---|---|---|---|
{{x | number}} | 1234.5 | en | 1,235 |
{{x | number:"2"}} | 1234.5 | en | 1,234.50 |
{{x | number:"2"}} | 1234.5 | de | 1.234,50 |
{{x | number:"2"}} | 1234.5 | fr | 1 234,50 (nnbsp) |
{{x | number:"0-2"}} | 1234.5 | en | 1,234.5 |
{{x | number:"0-2"}} | 19 | en | 19 |
{{x | number:"0-2"}} | 5.5 | de | 5,5 |
{{x | number:"1-2"}} | 5.555 | en | 5.56 |
{{x | number:"1"}} | -1234.5 | en | -1,234.5 |
{{x | number}} | 2.5 | en | 3 |
- Without an argument,
numberrounds to a whole number. Halves round away from zero. "2"prints exactly two decimals. A range such as"0-2"prints up to two and drops trailing zeros, which suits VAT rates like 19 and 5.5.- The argument is a single digit (0 to 9) or a range of two digits. Anything else, such as
"10", counts as no argument.
percent
| Template string | Value | Language | Output |
|---|---|---|---|
{{rate | percent}} | 0.19 | en | 19% |
{{rate | percent:"1"}} | 0.055 | en | 5.5% |
{{rate | percent:"1"}} | 0.055 | de | 5,5% |
{{rate | percent}} | 19 | en | 1,900% |
percent expects a fraction and multiplies it by 100. If your data already holds percentages, such as a VAT rate of 19, use {{rate | number:"0-2"}}% instead.
upper and lower
| Template string | Value | Output |
|---|---|---|
{{name | upper}} | "Ada Lovelace" | ADA LOVELACE |
{{name | upper}} | "straße" | STRASSE |
{{code | lower}} | "ADA" | ada |
default
| Template string | Value | Output |
|---|---|---|
{{po | default:"n/a"}} | missing or null | n/a |
{{po | default:"n/a"}} | "" | n/a |
{{po | default:"n/a"}} | 0 | 0 |
{{po | default:"n/a"}} | false | false |
{{po | default:"n/a"}} | "PO-77" | PO-77 |
The fallback is plain text. It can't contain | or }}.
Language and number formats
The render's language, or the template's default language when a request names none, decides the separators and the default date format:
| Languages | Numbers | Default date |
|---|---|---|
en | 1,234.50 | Nov 22, 2026 |
fr | 1 234,50 (nnbsp) | 22/11/2026 |
es, it, pt | 1.234,50 | 22/11/2026 |
nl | 1.234,50 | 22-11-2026 |
bg, ca, cs, da, de, el, et, fi, hr, hu, is, lb, lt, lv, nb, no, pl, ro, ru, sk, sl, sv, tr, uk | 1.234,50 | 22.11.2026 |
Any other code, such as ga (Irish) or mt (Maltese) | 1,234.50 | 22.11.2026 |
The language changes how an amount is formatted, not its currency: money without an argument always uses the template's currency.
Formatting marks
| Write | Result |
|---|---|
**bold** | bold |
*italic* | italic |
**bold *and italic*** | bold and italic |
[label](https://example.com) | A link. The URL must start with https://, http:// or mailto:. |
| A line break | A line break in the PDF. |
Marks apply to bindings inside them: **{{customer.name}}** prints the name in bold, and [Invoice {{invoice.number}}](https://example.com/pay) makes it part of the link text.
- A link's URL is used exactly as written, bindings included:
[Pay](https://pay.example.com/{{invoice.number}})links to a URL that literally contains{{invoice.number}}. Links can't be built from data. A QR code can. - If the URL doesn't start with one of the allowed schemes, the whole
[label](url)prints as text. - An unclosed
**or*is a validation error. A lone asterisk, as inPrices marked * include VAT, opens italic text, so escape it:Prices marked \* include VAT.
Escaping
A backslash prints the next character literally:
| Write | Prints |
|---|---|
\{{name}} | {{name}} |
\* | * |
\[ | [ |
\\ | \ |
Single braces, and }} without an opening {{, need no escaping. When you send a template string inside JSON, for example through the MCP server, escape the backslash itself: "\\{{name}}".
Data never needs escaping. A customer name such as **ACME** {{x}} prints exactly like that, without bold and without a binding.
Where template strings work
| Field | Template string | Notes |
|---|---|---|
| Text and heading content | Yes | |
| Table cell | Yes | The row alias is in scope: {{item.qty}}. |
| Table totals value | Yes | Binds top-level fields such as {{totals.amount | money}}, not the row alias. |
| QR / Barcode value | Yes | Evaluated to plain text before the code is drawn: marks are dropped, money prints the currency code (USD 4,800.00) and date leaves the value unformatted. |
| Signature signer | Yes | For example {{landlord.name}}. |
| Table column header, totals label, empty-table text | No | Plain text, printed as written. |
| Signature label, chart title, image alt text | No | Plain text. |
| Document title, watermark | No | Plain text. |
| Page number format | No | Takes the placeholders {page} and {total}. |
| Image source | No | Choose a fixed URL or an image variable on the block. |
Batch filename_pattern | Partly | Supports {{path}} with the upper, lower and default filters; other filters insert the raw value. See Batches. |
The filename of a single POST /v1/documents request is used as written, without bindings.
Conditional blocks and repeating rows
Template strings have no if or loop syntax. Blocks do the job instead.
Repeating rows. A Table block repeats one row per item of a list variable (its each, such as line_items) and names the current row with an alias (item by default). Tables can sort rows by a field, hide themselves or show a text when the list is empty, and end with totals rows.
Conditional blocks. Any block can have a visibility condition, set under Visibility in the block's settings. The block prints only when the condition holds. The invoice-standard starter uses one to print the payment QR code only when payment.url is not empty.
| Condition | API name | True when |
|---|---|---|
| is not empty | notEmpty | The value is present and, for text, lists and objects, not empty. |
| exists | exists | The value is present and not null. |
| is true / non-zero | truthy | The value isn't null, false, "" or 0, and isn't an empty list or object. |
| equals | eq | The value equals the given value, compared as text, so 3 equals "3". |
| does not equal | neq | The opposite of eq. |
| is greater than, is at least, is less than, is at most | gt, gte, lt, lte | Both sides are numbers (or numeric strings) and the comparison holds. Otherwise false. |
A block has one condition, on a payload field such as payment.url; it can't test a field of a table row. To require two conditions, put the block in a Box with its own condition: the box's condition and the block's both have to hold.
Safety
Template strings can't inject code into the rendering engine. The literal text of a template reaches the Typst engine only as escaped string literals, and payload data never becomes part of the template source: it's read from a separate JSON file and printed as plain text. A customer name such as #set page(paper: "a7") prints as those characters and changes nothing about the layout.