Handlebars syntax

PDFox templates use Handlebars for data binding. All expressions are HTML-escaped by default.

Variable interpolation

Access any field from your JSON data payload using double-curly-brace syntax. Nested fields use dot notation.

Conditionals

Use {{#if}} / {{else}} / {{/if}} to render content conditionally. Falsy values (false, 0, "", null, empty array) hide the block.

Loops

Use {{#each array}} to iterate. Inside the block, this refers to the current item. Use @index for the zero-based index.

Unescaped HTML

Triple braces {{{}} render HTML without escaping. Only use this for trusted HTML you control — never for user-supplied content.

Security: avoid triple braces with any data sourced from user input. PDFox sandboxes template rendering, but HTML injection can still distort your PDF layout.

Helpers

PDFox provides a set of built-in helpers like formatCurrency, formatDate, and eq. See the full list on the Template helpers page.

Custom helpers are not supported. Use the built-in set and transform data server-side before passing it as data if you need custom logic.
<p>Invoice for: {{customer.name}}</p>
<p>Reference: {{invoice.number}}</p>
<p>Total: {{formatCurrency invoice.total "GBP"}}</p>
{{#if invoice.isPaid}}
  <span class="badge paid">PAID</span>
{{else}}
  <span class="badge due">DUE</span>
{{/if}}
{{#each invoice.items}}
  <tr>
    <td>{{this.description}}</td>
    <td>{{formatCurrency this.amount "GBP"}}</td>
  </tr>
{{/each}}
{{! escaped by default: }}
<p>{{customer.name}}</p>

{{! unescaped HTML (use with caution): }}
<div>{{{signatureHtml}}}</div>