Skip to content
Get started

Template functions

Doquill adds these functions to every HTML and CSS file of a template, on top of Go’s built-in template functions. Arguments are separated by spaces. The value being formatted always comes last, so functions read naturally in a pipeline: {{ .total | currency "$" 2 }} is the same as {{ currency "$" 2 .total }}.

Numbers in your render data are JSON numbers, so the math and number functions work on them directly.

qrcode value [size]

Renders value as a QR code, returned as inline SVG. size is the optional width and height in pixels (default 150). Fails on an empty value.

Data
{
"url": "https://doquill.com"
}
Template
{{ qrcode .url 120 }}
barcode value [width] [height]

Renders value as a Code 128 barcode, returned as inline SVG. width defaults to twice the barcode’s module count and height to 60 pixels. Fails on an empty value.

Data
{
"number": "INV-1042"
}
Template
{{ barcode .number }}
epcQR name iban bic amount reference [size]

Renders a SEPA Credit Transfer QR code (EPC QR, also called GiroCode) as inline SVG, so the payer’s banking app can scan a EUR invoice into a prefilled transfer. name is the beneficiary, iban and bic its account, amount the sum in euros (the payload is always EUR), reference free-form remittance text such as the invoice number, and size the optional pixel size (default 150). Only meaningful for EUR invoices from a beneficiary in the SEPA zone.

iban and bic are format- and checksum-validated, and name and reference must not contain line breaks. Invalid input fails the render rather than producing a QR code with wrong payment details, so give iban and bic a pattern in the template’s JSON Schema to reject bad input before rendering.

Data
{
"company": {
"bic": "COBADEFFXXX",
"iban": "DE89370400440532013000",
"name": "Acme GmbH"
},
"number": "INV-1042",
"total": 1240.5
}
Template
{{ epcQR .company.name .company.iban .company.bic .total .number }}
finnishBarcode iban amount reference dueDate [size]

Renders a Finnish bank payment barcode (pankkiviivakoodi, Finance Finland spec, national reference form) as a Code 128 SVG, so a Finnish banking app can scan an invoice into a prefilled payment. iban must be a Finnish IBAN (FI…), amount at most 999999.99, reference the Finnish reference number (viitenumero) including its check digit, exactly as printed (grouping spaces are stripped), and dueDate anything dateFormat accepts. size is the optional pixel width.

The IBAN and reference check digits are validated, so a mistyped account or reference fails the render instead of producing a barcode that pays the wrong place. The international RF reference form is not supported.

Data
{
"due_at": "2026-11-30",
"iban": "FI37 1590 3000 0007 76",
"reference": "11112",
"total": 12.25
}
Template
{{ finnishBarcode .iban .total .reference .due_at }}
number decimals value

Formats value with thousands separators and a fixed number of decimals.

Template
{{ number 2 1234.5 }}
Output1,234.50
Data
{
"count": 1500000
}
Template
{{ .count | number 0 }}
Output1,500,000
currency symbol decimals value

Formats value like number and prefixes symbol. Negative amounts put the sign before the symbol.

Data
{
"total": 1240
}
Template
{{ currency "$" 2 .total }}
Output$1,240.00
Template
{{ currency "€" 2 -5 }}
Output-€5.00
percent decimals value

Multiplies value by 100 and appends %, so pass the fraction (0.25), not the percentage.

Template
{{ percent 1 0.25 }}
Output25.0%
dateFormat layout value

Formats a date. value is a time (such as now) or a string in RFC 3339 (2026-01-05T09:30:00Z) or YYYY-MM-DD form. layout is a Go reference layout: write how the reference time Mon Jan 2 15:04:05 MST 2006 should look, e.g. 2006-01-02 or Jan 2, 2006.

Data
{
"issued_at": "2026-01-05"
}
Template
{{ dateFormat "Jan 2, 2006" .issued_at }}
OutputJan 5, 2026
Data
{
"paid_at": "2026-01-05T09:30:00Z"
}
Template
{{ dateFormat "02.01.2006 15:04" .paid_at }}
Output05.01.2026 09:30
now

The current time in UTC, for use with dateFormat.

Template
{{ dateFormat "2006-01-02" now }}
upper s

Converts s to upper case.

Template
{{ upper "paid" }}
OutputPAID
lower s

Converts s to lower case.

Template
{{ lower "PAID" }}
Outputpaid
title s

Capitalises the first letter of each word and lower-cases the rest.

Template
{{ title "ada LOVELACE" }}
OutputAda Lovelace
trim s

Removes leading and trailing whitespace.

Template
[{{ trim " INV-1042 " }}]
Output[INV-1042]
replace old new s

Replaces every occurrence of old in s with new.

Template
{{ replace "-" "/" "2026-01-05" }}
Output2026/01/05
truncate n s

Shortens s to n characters, appending … when anything was cut. Counts characters, not bytes.

Data
{
"note": "Thanks for your business"
}
Template
{{ truncate 10 .note }}
OutputThanks for…
add a b

Returns a + b.

Data
{
"subtotal": 100,
"tax": 24
}
Template
{{ add .subtotal .tax }}
Output124
sub n value

Returns value - n. The amount to subtract comes first so it reads naturally in a pipeline.

Data
{
"qty": 5
}
Template
{{ .qty | sub 1 }}
Output4
mul a b

Returns a * b.

Data
{
"quantity": 3,
"unit_price": 12.5
}
Template
{{ mul .quantity .unit_price }}
Output37.5
div n value

Returns value / n. The divisor comes first so it reads naturally in a pipeline. Dividing by zero fails the render.

Data
{
"total": 100
}
Template
{{ .total | div 4 }}
Output25
round decimals n

Rounds n to decimals places.

Template
{{ round 2 3.14159 }}
Output3.14
asset alias

Returns a URL for the workspace asset uploaded under alias. Use it in HTML (<img src="{{ asset "logo" }}">) or in CSS (background-image: url({{ asset "logo" }})). The render fails if no asset has that alias.

Template
<img src="{{ asset "logo" }}" alt="Logo">