Skip to content

Handlebars Helpers – Complete Reference

Pantarey uses Handlebars templates in several places – for PDF generation, text templates, and external tasks. All templates share the same set of helper functions for formatting, calculating, and preparing data directly within the template.

This makes it possible to produce professional invoices, reports, and notifications without additional process steps.


Where are Handlebars templates used?

Use case Service / Feature
PDF documents Generate PDF from Handlebars template
Text generation Generate text from Handlebars template
Emails from template Send email from Handlebars template (Microsoft Graph)
External tasks External User Task – HTML templates

Basics

Handlebars placeholders use double curly braces:

<p>Customer: {{customerName}}</p>
<p>Amount: {{currency_eur invoiceAmount}}</p>

Values come from the content object passed to the service task.

Triple curly braces for HTML

By default, Handlebars escapes HTML special characters. When the output contains HTML (e.g. qrCode or htmlify), triple curly braces {{{ }}} must be used.


Date and Time

Helper Description Example Result
dateTimeFormat Format ISO date to localized date/time {{dateTimeFormat createdAt "en-US" "Europe/Berlin"}} 12/22/2024, 11:30 AM
dateTimeFormatWithSettings Format date/time with extended options {{dateTimeFormatWithSettings date "en-US" "Europe/Berlin"}} 12/22/2024, 11:30 AM
toGermanDate ISO date → German format {{toGermanDate "2025-01-15"}} 15.01.2025
currentDate Today's date {{currentDate "en-US" "Europe/Berlin"}} 4/8/2026
currentDateTime Today's date and time {{currentDateTime "en-US" "Europe/Berlin"}} 4/8/2026, 2:30 PM
addDaysToCurrentDate Add days to today's date {{addDaysToCurrentDate 14}} 22.04.2026
month_name Month name from date {{month_name "2025-03-15"}} März
year Year from date {{year "2025-03-15"}} 2025

Example – payment due date:

<p>Invoice date: {{toGermanDate invoiceDate}}</p>
<p>Due by: {{addDaysToCurrentDate 30}}</p>

Numbers and Currency

Helper Description Example Result
currency_eur Euro formatting {{currency_eur 1234.56}} 1.234,56 €
currency_dollar Dollar formatting {{currency_dollar 1234.56}} $1,234.56
numberFormat Number with thousands separator {{numberFormat 50000}} 50.000
multiply Multiplication {{multiply price quantity}}
add Addition {{add value1 value2}}
round Round to decimal places {{round 3.14159 2}} 3.14

Example – invoice line item:

<td>{{numberFormat quantity}} pcs.</td>
<td>{{currency_eur unitPrice}}</td>
<td>{{currency_eur (multiply unitPrice quantity)}}</td>

Conditions

Condition helpers are block helpers – they wrap content that is only displayed when the condition is met.

Helper Description Example
ifEquals Equality check {{#ifEquals status "approved"}}Approved{{/ifEquals}}
greaterThan Greater than {{#greaterThan amount 1000}}Large order{{/greaterThan}}
lessThan Less than {{#lessThan amount 100}}Small amount{{/lessThan}}
greaterOrEqualThan Greater than or equal {{#greaterOrEqualThan score 50}}Passed{{/greaterOrEqualThan}}
lessOrEqualThan Less than or equal {{#lessOrEqualThan stock 10}}Reorder{{/lessOrEqualThan}}

All condition helpers support an {{else}} block:

{{#greaterThan amount 1000}}
  <span class="highlight">Large order</span>
{{else}}
  <span>Standard order</span>
{{/greaterThan}}

Text and Formatting

Helper Description Example
replace Replace text {{replace companyName "GmbH" "AG"}}
htmlify Line breaks → <br>, page breaks → Page Break {{{htmlify description}}}
renderString Evaluate a Handlebars expression within a string {{{renderString dynamicText this}}}
buildString Concatenate strings (e.g. as sub-expression) {{{qrCode (buildString "BCD\n" bic "\n" name)}}}

htmlify in detail

The htmlify helper converts plain text to HTML:

  • Line breaks (\n) become <br>
  • <pagebreak> becomes a page break (for PDFs)
<div>{{{htmlify freeTextField}}}</div>

Triple curly braces

htmlify and renderString return HTML – always use {{{ }}}.


Lists and Pagination

Helper Description Example
concat Merge arrays {{#each (concat listA listB)}}...{{/each}}
paginate Split array into pages {{#paginate items 10}}...{{/paginate}}

paginate in detail

The paginate helper splits an array into equal-sized chunks – ideal for multi-page PDFs where, for example, only 10 line items should appear per page.

{{#paginate items 10}}
  <div class="page">
    <h2>Page {{add pageIndex 1}}</h2>
    <table>
      {{#each slice}}
        <tr>
          <td>{{this.description}}</td>
          <td>{{currency_eur this.amount}}</td>
        </tr>
      {{/each}}
    </table>
  </div>
{{/paginate}}

Within the block, the following variables are available:

  • slice – the entries for the current page
  • pageIndex – the page index (starts at 0)

QR Code

Helper Description Example
qrCode Generate QR code as data URL <img src="{{{qrCode paymentLink}}}" width="200" />
buildString Concatenate strings (e.g. for structured QR data) {{{qrCode (buildString "BCD\n" bic "\n" name)}}}

QR codes are generated as Base64 data URLs and embedded directly in an <img> tag. Sizing and positioning are controlled via HTML/CSS.

Options

Option Default Description
width 200 Image width in pixels
margin 1 Margin around the QR code (in modules)
errorCorrectionLevel "M" Error correction: "L", "M", "Q", or "H"
<img src="{{{qrCode productUrl width=300 margin=2 errorCorrectionLevel="H"}}}" width="300" />

GiroCode example (payment QR code)

The GiroCode (EPC QR code) allows bank transfer data to be scanned directly by banking apps. The format follows a fixed line structure:

<img src="{{{qrCode (buildString
  "BCD\n001\n1\nSCT\n"
  bic "\n"
  recipientName "\n"
  iban "\nEUR"
  amount "\n\n\nInvoice "
  invoiceNumber
) width=250 errorCorrectionLevel="M"}}}" width="250" />

Triple curly braces required

qrCode returns a data URL containing data:image/png;base64,.... With double curly braces {{ }}, the result would be HTML-escaped and the image would not display.


Practical Example: Invoice

The following example shows a complete invoice template with header, line items, totals, payment QR code, and conditional note:

<html>
<body>
  <h1>Invoice {{invoiceNumber}}</h1>
  <p>Date: {{toGermanDate invoiceDate}}</p>
  <p>Customer: {{customerName}}</p>

  <table>
    <thead>
      <tr>
        <th>Description</th>
        <th>Quantity</th>
        <th>Unit Price</th>
        <th>Total</th>
      </tr>
    </thead>
    <tbody>
      {{#each items}}
      <tr>
        <td>{{this.description}}</td>
        <td>{{numberFormat this.quantity}}</td>
        <td>{{currency_eur this.unitPrice}}</td>
        <td>{{currency_eur (multiply this.unitPrice this.quantity)}}</td>
      </tr>
      {{/each}}
    </tbody>
  </table>

  <p><strong>Net amount:</strong> {{currency_eur netAmount}}</p>
  <p><strong>VAT 19%:</strong> {{currency_eur (multiply netAmount 0.19)}}</p>
  <p><strong>Total:</strong> {{currency_eur grossAmount}}</p>

  {{#greaterThan grossAmount 500}}
    <p><em>Please transfer the amount within 14 days.</em></p>
  {{/greaterThan}}

  <div style="margin-top: 20px;">
    <p>Scan to transfer:</p>
    <img src="{{{qrCode (buildString "BCD\n001\n1\nSCT\n" bic "\n" companyName "\n" iban "\nEUR" grossAmount "\n\n\nInvoice " invoiceNumber)}}}" width="200" />
  </div>

  <footer>
    <p>Created on {{currentDate "en-US" "Europe/Berlin"}}</p>
  </footer>
</body>
</html>

All Helpers at a Glance

Helper Category Triple braces needed
dateTimeFormat Date No
dateTimeFormatWithSettings Date No
toGermanDate Date No
currentDate Date No
currentDateTime Date No
addDaysToCurrentDate Date No
month_name Date No
year Date No
currency_eur Numbers No
currency_dollar Numbers No
numberFormat Numbers No
multiply Numbers No
add Numbers No
round Numbers No
ifEquals Condition No
greaterThan Condition No
lessThan Condition No
greaterOrEqualThan Condition No
lessOrEqualThan Condition No
replace Text No
htmlify Text Yes
renderString Text Yes
buildString Text — (sub-expression)
concat Lists No
paginate Lists No
qrCode QR Code Yes