Template Language
The template operation (CLI pidief template, API POST /v1/template) turns an HTML template and JSON data into a PDF. template preview returns the rendered HTML instead.
Templates use Mustache placeholders ({{customer.name}}, {{#items}}…{{/items}}) plus Handlebars blocks and helpers. Helpers have both Turkish and English names.
Syntax and helpers
| Syntax | Purpose |
|---|---|
{{a.b}} / {{{html}}} | HTML-escaped / raw value |
{{#each list}}…{{else}}…{{/each}}, {{#each list as |item|}} | loop; @index, @number, @first, @last, ../parent |
{{#if x}}…{{else if y}}…{{else}}…{{/if}}, {{#unless}}, {{#with}}, {{^list}} | conditions |
{{currency total}} / {{para total}} → ₺1.234,56; "USD" → $1.234,56; "TL" → 1.234,56 TL | money (tr-TR grouping) |
{{number x 2}} / {{sayi x 2}} → 1.234,57; {{percent 18}} / {{yuzde 18}} → %18 | numbers |
{{date d}} / {{tarih d}} → 18.11.2026; {{date d "d MMMM yyyy dddd"}} → 18 Kasım 2026 Çarşamba; {{today}} | dates (.NET format letters, Turkish month and day names) |
{{inwords 1234.56}} / {{yaziyla 1234.56}} → bin iki yüz otuz dört Türk lirası elli altı kuruş | amount in words (Turkish) |
{{upper "istanbul"}} → İSTANBUL, lower, title | Turkish-aware casing |
{{sum items "amount"}}, add/sub/mul/div/round, eq/ne/gt/lt/and/or/not, default, join, length | math (exact decimals) and logic |
Options
--strictfails when a value is missing.--empty "-"sets the text printed for empty values.- Dates use the
timezoneparameter (defaultEurope/Istanbul).
Example
pidief template invoice.html data.json --strict --empty "-" -o invoice.pdf
pidief template preview invoice.html data.json -o preview.html
Over HTTP, template and data can be sent directly in a JSON body:
curl -H "X-Api-Key: $KEY" -H 'Content-Type: application/json' http://localhost:3000/v1/template \
-d '{"template":"<h1>{{customer.name}}</h1><p>{{currency total \"EUR\"}}</p>","data":{"customer":{"name":"Example Ltd"},"total":1234.56}}' -o receipt.pdf
Turkish defaults
Turkish characters and the embedded Onest font work by default. The default page number text is "Sayfa X / Y", and the template helpers use tr-TR formatting.