Built-in Functions
This page lists the five functions available inside {{ }} and the limits of each.
Function List
| Function | Syntax | Result |
|---|---|---|
LENGTH() |
{{ LENGTH(items) }} |
Length of an array or string; key count for objects |
CALC() |
{{ CALC(price * 1.05) }} |
Arithmetic between a data value and a number literal |
UPPER() |
{{ UPPER(name) }} |
Uppercase |
LOWER() |
{{ LOWER(name) }} |
Lowercase |
DATE() |
{{ DATE(timestamp, YYYY-MM-DD HH:mm) }} |
Formats a UNIX timestamp in seconds |
Function names must be uppercase and only one level is allowed; functions cannot be nested.
CALC()
<p>{{ CALC(price * 1.05) }}</p>
<p>{{ CALC(count + 1) }}</p>
| Limit | Description |
|---|---|
| Operators | +, -, *, / |
| Right-hand side | Must be a number literal, not another data key |
% |
Supported by the calculator, but the {{ }} pattern does not accept %, so it is never replaced in a template |
| Non-numeric | If either side cannot be converted to a number, {{ }} stays as written |
UPPER() / LOWER()
The value must be a string; a null or missing value throws a TypeError and aborts that render.
DATE()
<p>{{ DATE(now, YYYY-MM-DD HH:mm:ss) }}</p>
<script>
const app = new QUI({
id: "app",
data: { now: Math.floor(Date.now() / 1000) },
});
</script>
| Token | Output |
|---|---|
YYYY / YY |
Four-digit / two-digit year |
MM / M |
Zero-padded / unpadded month |
DD / D |
Zero-padded / unpadded day |
HH / H |
24-hour clock |
hh / h |
12-hour clock |
mm / m, ss / s |
Minutes, seconds |
SSS |
Milliseconds |
A / a |
AM / PM, am / pm |
ddd |
Weekday; 星期一 when the browser language contains zh, otherwise the English abbreviation (Mon) |
The format string only accepts letters, digits, spaces, -, : and ,; with / or . it is not recognized as DATE() and {{ }} stays as written.