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
Section titled “qrcode”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.
{ "url": "https://doquill.com"}{{ qrcode .url 120 }}barcode
Section titled “barcode”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.
{ "number": "INV-1042"}{{ 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.
{ "company": { "bic": "COBADEFFXXX", "iban": "DE89370400440532013000", "name": "Acme GmbH" }, "number": "INV-1042", "total": 1240.5}{{ epcQR .company.name .company.iban .company.bic .total .number }}finnishBarcode
Section titled “finnishBarcode”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.
{ "due_at": "2026-11-30", "iban": "FI37 1590 3000 0007 76", "reference": "11112", "total": 12.25}{{ finnishBarcode .iban .total .reference .due_at }}Numbers
Section titled “Numbers”number
Section titled “number”number decimals value
Formats value with thousands separators and a fixed number of decimals.
{{ number 2 1234.5 }}1,234.50{ "count": 1500000}{{ .count | number 0 }}1,500,000currency
Section titled “currency”currency symbol decimals value
Formats value like number and prefixes symbol. Negative amounts put the sign before the symbol.
{ "total": 1240}{{ currency "$" 2 .total }}$1,240.00{{ currency "€" 2 -5 }}-€5.00percent
Section titled “percent”percent decimals value
Multiplies value by 100 and appends %, so pass the fraction (0.25), not the percentage.
{{ percent 1 0.25 }}25.0%dateFormat
Section titled “dateFormat”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.
{ "issued_at": "2026-01-05"}{{ dateFormat "Jan 2, 2006" .issued_at }}Jan 5, 2026{ "paid_at": "2026-01-05T09:30:00Z"}{{ dateFormat "02.01.2006 15:04" .paid_at }}05.01.2026 09:30now
The current time in UTC, for use with dateFormat.
{{ dateFormat "2006-01-02" now }}Strings
Section titled “Strings”upper s
Converts s to upper case.
{{ upper "paid" }}PAIDlower s
Converts s to lower case.
{{ lower "PAID" }}paidtitle s
Capitalises the first letter of each word and lower-cases the rest.
{{ title "ada LOVELACE" }}Ada Lovelacetrim s
Removes leading and trailing whitespace.
[{{ trim " INV-1042 " }}][INV-1042]replace
Section titled “replace”replace old new s
Replaces every occurrence of old in s with new.
{{ replace "-" "/" "2026-01-05" }}2026/01/05truncate
Section titled “truncate”truncate n s
Shortens s to n characters, appending … when anything was cut. Counts characters, not bytes.
{ "note": "Thanks for your business"}{{ truncate 10 .note }}Thanks for…add a b
Returns a + b.
{ "subtotal": 100, "tax": 24}{{ add .subtotal .tax }}124sub n value
Returns value - n. The amount to subtract comes first so it reads naturally in a pipeline.
{ "qty": 5}{{ .qty | sub 1 }}4mul a b
Returns a * b.
{ "quantity": 3, "unit_price": 12.5}{{ mul .quantity .unit_price }}37.5div n value
Returns value / n. The divisor comes first so it reads naturally in a pipeline. Dividing by zero fails the render.
{ "total": 100}{{ .total | div 4 }}25round decimals n
Rounds n to decimals places.
{{ round 2 3.14159 }}3.14Assets
Section titled “Assets”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.
<img src="{{ asset "logo" }}" alt="Logo">