Text templates (Liquid profile)
User-facing text (title, label, hint, constraintMessage, choice labels) may contain
Liquid:
Hej {{ applicant.name }}
Du kan højst låne {{ loan.max_amount }} kr.
{% if loan.max_amount %}…{% endif %}Liquid is used for text only. Rules are formulas: Liquid always produces strings, its conditions have no parentheses and evaluate right to left, and engines differ in edge cases. Those are acceptable for display text but not for validation.
Context
A template sees:
- the form data as nested objects (
applicant.name,loan.amount). Hidden fields are absent, and blank fields arenil; - data-source results under
ds(ds.company.name). This is whydsis a reserved name.
Allowed tags and filters
Only this subset is allowed, because it behaves the same in liquidjs (browser, Node) and Fluid (.NET). The compiler rejects everything else.
- Tags:
if/elsif/else,unless,case/when,for(withbreak,continue),assign,capture,raw,comment - Filters:
abs append capitalize ceil default divided_by downcase first floor join last lstrip minus modulo plus prepend remove replace round rstrip size slice split strip times truncate upcase
date is deliberately excluded because its format strings differ between engines; a
quillflow date filter with a shared definition will replace it.
quillflow filters
Defined here, not by Liquid, and implemented identically by every runtime:
number
{{ value | number }} formats a number the way the form's current language writes it, and
{{ value | number: 2 }} does the same with a fixed number of decimals.
| Language (primary subtag) | Decimal mark | Thousands separator | 1234567.5 |
9734.355 | number: 2 |
|---|---|---|---|---|
| da, de, es, it, nl, pt | , |
. |
1.234.567,5 |
9.734,36 |
| fi, fr, nb, nn, no, pl, sv | , |
U+00A0 no-break space | 1 234 567,5 |
9 734,36 |
| anything else | . |
, |
1,234,567.5 |
9,734.36 |
- Without an argument, the digits are the shortest round-trip form (as in formulas).
Numbers that form would write with an exponent (
1e+21) are output unchanged. - With
decimals(a whole number 0–10), the number is rounded half away from zero, likeROUND, and always shown with that many decimals:5 | number: 2→5,00. - Negative numbers get a leading
-, unless rounding makes them zero. - Blank gives an empty string. Anything that is not a number is output unchanged.
The same table is used to read numbers that people type into number fields, so what a form shows is always something it accepts.
Output
Rendered text is plain text: hosts must insert it with textContent (or the framework
equivalent), never as HTML. That makes Liquid output escaping unnecessary.