v0.6.22

Built-in Functions

Last updated


This page lists the five functions available inside {{ }} and the limits of each.

Function List


FunctionSyntaxResult
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()


  1. <div id="app">
  2. <p>{{ CALC(price * 1.05) }}</p>
  3. <p>{{ CALC(count + 1) }}</p>
  4. </div>
  5. <script>
  6. const app = new QUI({ id: "app", data: { price: 100, count: 1 } });
  7. </script>
Live preview · @pardnchiu/quickui@0.6.22

Supported operators: +, -, *, /.

UPPER() / LOWER()


The value must be a string; a null or missing value throws a TypeError and aborts that render.

DATE()


  1. <div id="app">
  2. <p>{{ DATE(now, YYYY-MM-DD HH:mm:ss) }}</p>
  3. </div>
  4. <script>
  5. const app = new QUI({
  6. id: "app",
  7. data: { now: Math.floor(Date.now() / 1000) },
  8. });
  9. </script>
Live preview · @pardnchiu/quickui@0.6.22

TokenOutput
YYYY / YYFour-digit / two-digit year
MM / MZero-padded / unpadded month
DD / DZero-padded / unpadded day
HH / H24-hour clock
hh / h12-hour clock
mm / m, ss / sMinutes, seconds
SSSMilliseconds
A / aAM / PM, am / pm
dddWeekday; 星期一 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.
中文