Templates
A template is HTML and CSS with a few extras. Values from data are inserted with
{{ }}, and {% %} adds logic. The syntax is Tera, close
to Jinja and Django templates.
<h1>Invoice {{ number }}</h1><p>{{ customer.name }}, issued {{ issued | date(style="long") }}</p>
<table> {% for item in items %} <tr> <td>{{ item.name }}</td> <td>{{ item.amount | currency(code="USD") }}</td> </tr> {% endfor %}</table>
{% if discount %}<p>Discount applied</p>{% endif %}
<p>Total {{ total | currency(code="USD") }}</p>Values
Section titled “Values”data is a JSON object. Reach into objects with a dot (customer.name) and loop over
arrays with {% for %}. A variable called locale is always available and holds the
locale of the render.
Values are HTML-escaped, so a customer name such as <b>Ana</b> appears as text, not as
markup. Your template is trusted markup; your data is not.
{% if x %}…{% elif y %}…{% else %}…{% endif %}and comparisons such asx > 1.{% for item in items %}withloop.index,loop.firstandloop.last.- Arithmetic:
{{ price * qty }}. {% set name = value %}to name an intermediate value.
Tera’s own filters (upper, lower, round, length and others) work too. The service
adds three for formatting; see Locales and formatting.
What templates cannot do
Section titled “What templates cannot do”Templates cannot include other files or read anything outside the render. The output of one render is capped by your plan, and a template that produces too much is refused.
Saving templates
Section titled “Saving templates”Create and edit templates in the portal, which previews and validates as you type, or through the API. A template must compile to be saved.
curl -X POST https://api.example.com/v1/templates \ -H "Authorization: Bearer $RUSTEDF_KEY" \ -H "Content-Type: application/json" \ -d '{ "name": "Invoice", "source": "<h1>{{ number }}</h1>", "locale": "en-US", "sample_data": { "number": "2025-0042" } }'sample_data is only for the portal’s preview. Each change raises the template’s
version. Templates belong to one account: another account’s template id is a 404.
Limits on data
Section titled “Limits on data”data must be a JSON object, at most 32 levels deep and 200,000 values, and no larger than
your plan’s input limit.