Skip to content

Templating (Jinja2)

Templates support Jinja2 placeholders inside any string value.

Basic

json
{ "type": "text", "value": "Hello {{ customer.name }}" }

Filters

date

json
{ "type": "text", "value": "{{ issued_at | date(\"%d/%m/%Y\") }}" }

datetime

json
{ "type": "text", "value": "{{ issued_at | datetime(\"%Y-%m-%d %H:%M\") }}" }

currency

json
{ "type": "text", "value": "Total: {{ total | currency(\"\", 2) }}" }

concat

json
{ "type": "text", "value": "{{ first | concat(\" \" ) | concat(last) }}" }

Expressions

You can use Jinja2 expressions:

json
{ "type": "text", "value": "{{ items | sum | currency(\"\", 2) }}" }

Data payload

When rendering with data, send a data object:

json
{
  "template": { "elements": [ { "type": "text", "value": "{{ total }}" } ] },
  "data": { "total": 123.45 }
}