Expressions
The small language used in templates, bindings and conditions.
Expressions are used in four places:
| Place | Written as | Example |
|---|---|---|
| Inside text | {{ expression }} | "Total: {{data.total * 1.24}}" |
| As a whole value | { "$expr": "expression" } | { "$expr": "data.items.length" } |
visibleWhen | The expression itself, no braces | "data.errors > 0" |
repeat.each | The expression itself, no braces | "data.tasks" |
Hookboard's own small interpreter evaluates expressions. They look a lot like JavaScript, but there are no statements, assignments or loops, and no way to reach the page.
What's in scope
| Name | What it is |
|---|---|
data | The card's data |
state | The card's local state |
item | The current item inside a repeat (or the name given by as) |
index | The position of the current item inside a repeat, starting at 0 |
Syntax
| Kind | Forms |
|---|---|
| Values | numbers 12, 3.5; text "hi" or 'hi'; true, false, null; lists [1, 2, 3] |
| Paths | data.user.name, data.rows[0], data.map["key"], optional data.user?.name |
| Arithmetic | + - * / %. + joins text when either side is text. |
| Comparison | == != < <= > >= (=== and !== mean the same as == and !=) |
| Logic | && || !, and ?? for "use the right side when the left is null" |
| Choice | condition ? a : b |
| Calls | name(arg, …) using the listed functions only |
A missing path gives null and never raises an error. You can only call the listed functions, so a value's own methods, such as text.toUpperCase(), won't work. Use upper(text) instead.
Examples
{
"data": {
"used": 412,
"total": 512,
"updated": "2026-11-28T09:12:00Z",
"tags": ["db", "eu"]
},
"ui": {
"type": "stack",
"children": [
{
"type": "progress",
"value": { "$expr": "round(data.used / data.total * 100)" },
"label": "Disk",
"showValue": true
},
{
"type": "text",
"value": "{{data.total - data.used}} GB free",
"tone": {
"$expr": "data.used / data.total > 0.9 ? 'danger' : 'muted'"
}
},
{
"type": "text",
"value": "Updated {{relativeTime(data.updated)}}",
"size": "sm",
"tone": "muted"
},
{
"type": "badge",
"repeat": { "each": "data.tags" },
"label": "{{upper(item)}}"
}
]
}
}If an expression can't be parsed, the card is rejected when you send it, with a 422 naming the property and the problem.