Templating syntax
Pritset templates use commands inside {{ and }} delimiters to insert data, repeat content, add links,
and generate images. Add these commands to a DOCX file, upload the template,
and then call the Template Processing API with matching JSON data to generate a PDF.
New to Pritset? Complete the quickstart. When your template is ready, use the API overview or go directly to Template processing.
The easiest way to learn the syntax is to compare a working DOCX template with its JSON payload and generated PDF.
Supported commandsโ
The commands below are supported by the current Pritset template-processing flow.
Insert a valueโ
Use a JavaScript expression between the delimiters to insert its result into the document.
For example, send this data:
{
project: {
name: "Clinic Operations Report",
url: "https://example.com/reports/clinic-operations",
logoUrl: "https://example.com/assets/clinic-logo.png",
people: [
{ name: "Jack Olson", since: 2005 },
{ name: "Alisa Taylor", since: 2007 },
{ name: "Amanda Wright", since: 2011 }
],
details: {
year: 2026
}
},
companies: [
{
name: "Northstar Health",
people: [
{
firstName: "Brandon",
projects: [
{ name: "Patient intake redesign" },
{ name: "Monthly operations dashboard" }
]
}
],
executives: ["Anna May", "Clare Adams"]
}
]
}
Use either of these forms in the DOCX template:
{{project.name}} ({{project.details.year}})
{{`${project.name} (${project.details.year})`}}
Both forms produce:
Clinic Operations Report (2026)
LINKโ
Insert a hyperlink from the result of a JavaScript expression:
{{LINK ({ url: project.url, label: project.name })}}
If label is omitted, the URL is used as the link text.
FOR and END-FORโ
Repeat content for each item produced by a JavaScript expression:
{{FOR person IN project.people}}
{{$person.name}} (since {{$person.since}})
{{END-FOR person}}
Inside the loop, prefix the variable for the current item with $.
Use $idx to get the zero-based index of the current item in the innermost loop:
{{FOR company IN companies}}
Company ({{$idx}}): {{$company.name}}
Executives:
{{FOR executive IN $company.executives}}
- {{$idx}} {{$executive}}
{{END-FOR executive}}
{{END-FOR company}}
FOR loops also work across table rows:
| Name | Since |
|---|---|
{{FOR person IN project.people}} | |
{{$person.name}} | {{$person.since}} |
{{END-FOR person}} |
Loops can be nested:
{{FOR company IN companies}}
{{$company.name}}
{{FOR person IN $company.people}}
* {{$person.firstName}}
{{FOR project IN $person.projects}}
- {{$project.name}}
{{END-FOR project}}
{{END-FOR person}}
{{END-FOR company}}
IMAGEโ
Use readImage to download an image from a publicly accessible URL and insert it into the document:
{{IMAGE readImage(4, 3, project.logoUrl, ".png")}}
width: Desired image width in centimeters.height: Desired image height in centimeters.url: Public URL that the Pritset templating service can fetch.extension: Image extension, such as".png",".gif",".jpg", or".jpeg".
Choose width and height values that preserve the source image's aspect ratio to avoid stretching.
Chartsโ
Use drawChart to generate a Chart.js chart and insert it as an image:
{{IMAGE drawChart(type, width, height, data)}}
type: Chart.js chart type. The examples below use"bar","pie", and"line".width: Canvas width in pixels.height: Canvas height in pixels.data: Chart.js data object for the selected chart type.
The service converts the canvas dimensions to document dimensions when it inserts the generated chart.
Bar chart dataโ
{
"labels": ["January", "February"],
"datasets": [
{
"label": "Documents generated",
"data": [1200, 1680],
"backgroundColor": [
"rgba(37, 89, 99, 0.5)",
"rgba(249, 147, 45, 0.5)"
]
}
]
}
Pie chart dataโ
{
"labels": ["Invoices", "Reports"],
"datasets": [
{
"label": "Document types",
"data": [300, 120],
"backgroundColor": [
"#E87F24",
"rgb(54, 162, 235)"
]
}
]
}
Line chart dataโ
{
"labels": [
"October 2025",
"November 2025",
"December 2025",
"January 2026"
],
"datasets": [
{
"label": "Documents generated",
"data": [1000, 1500, 2000, 2500],
"fill": false,
"borderColor": "rgb(37, 89, 99)",
"backgroundColor": "rgba(37, 89, 99, 0.2)"
}
]
}