Template-functions
Overview
Pantarey templates (e.g. documentNameTemplate, businessLabel) support functions:
$fn('function_name', $(parameter1), $(parameter2), ...)
Parameters are always referenced using $(parametername).
Benefit:
Clean, standardized and automated names and labels without additional process or script logic.
Basics
- Parameters use
$(...) - Functions are tolerant
- Functions can be nested
- Same syntax works in templates and JSONata
| Input | Function | Result |
|---|---|---|
$(customer_name) = Müller GmbH |
$fn('str_upper', $(customer_name)) |
MÜLLER GMBH |
String Functions (most common)
| Function | Description | Example | Result |
|---|---|---|---|
str_trim(value) |
Trim spaces | $fn('str_trim', $(title)) |
Invoice |
str_upper(value) |
Uppercase | $fn('str_upper', $(customer_name)) |
MÜLLER GMBH |
str_lower(value) |
Lowercase | $fn('str_lower', $(CODE)) |
ab123 |
str_slice(value, from, to) |
Slice by index | $fn('str_slice', $(order_id), 0, 6) |
ORD-20 |
str_substring(value, from, to) |
Substring | $fn('str_substring', $(filename), 0, 8) |
invoice |
str_replaceAll(value, s, r) |
Replace text | $fn('str_replaceAll', $(name), ' ', '_') |
Mueller_GmbH |
str_padStart(value, len, c) |
Left padding | $fn('str_padStart', $(invoice_no), 6, '0') |
000123 |
str_padEnd(value, len, c) |
Right padding | $fn('str_padEnd', $(code), 5, '-') |
A1--- |
Number Functions
| Function | Description | Example | Result |
|---|---|---|---|
number_add(a, b) |
Addition | $fn('number_add', $(net), $(tax)) |
119 |
number_sub(a, b) |
Subtraction | $fn('number_sub', $(total), $(discount)) |
90 |
number_multiply(a, b) |
Multiply | $fn('number_multiply', $(qty), $(price)) |
59.8 |
number_divide(a, b) |
Divide | $fn('number_divide', $(sum), $(count)) |
25 |
number_round(v, d) |
Round | $fn('number_round', $(amount), 2) |
19.99 |
Date & System Functions
| Function | Description | Example | Result |
|---|---|---|---|
date_toPath(value) |
Date folder | $fn('date_toPath', $(created_at)) |
2025/12/14 |
date_toGermanDate(value) |
German date | $fn('date_toGermanDate', $(invoice_date)) |
14.12.2025 |
sys_ulid() |
Generate ULID | $fn('sys_ulid') |
01JEF… |
nextId(name) |
Sequential counter | $fn('nextId', 'invoice') |
1024 |
sys_nextCounter(name) |
Counter (alias for nextId) |
$fn('sys_nextCounter', 'invoice') |
1024 |
Counters in detail
Sequential numbers for invoices, orders or tickets are managed via Counters – including an admin interface for manually setting and correcting values.
Real-World Examples
INV-$fn('str_upper', $(customer_code))-$fn('str_padStart', $(invoice_no), 4, '0')
Do’s & Don’ts
✅ Do
- Use for formatting and standardization
- Prefer string functions
- Keep templates readable
❌ Don’t
- Implement business logic
- Force complex calculations
- Use unknown function names
FAQ
Are empty values supported?
Yes. Missing values do not break rendering.
Can functions be nested?
Yes, without limits.
When should JSONata be used instead?
For complex logic, conditions or aggregations.
Summary:
$fn() makes Pantarey templates powerful but controlled – ideal for clean automation.