Expressions

XML page expressions use a safe JavaScript expression subset parsed with Acorn. LongLink evaluates only approved syntax against the XML runtime scope; it does not execute arbitrary JavaScript.

Syntax Forms

  • $draft.title reads a runtime value and creates a writable binding for controls that support bindings.
  • ${draft.title} evaluates a typed expression and returns the expression result.
  • /requests/${params.request} interpolates expression results inside a string parameter.
  • Plain text stays literal unless it is a dotted runtime path, a $ reference, or contains${...} interpolation.

Runtime Scope

Expressions can read values exposed by setup nodes, route params, and loop scopes.

  • State values are reactive local page objects, such as draft.title.
  • Query values are JSON responses stored under their query id, such as tasks.length.
  • For exposes the item alias and index inside the loop body.
  • Dynamic page files expose route parameters through params.

Operators

Supported operators cover page conditions, derived values, and request payloads.

  • Arithmetic: +, -, *, /, %, and **.
  • Equality and comparison: ===, !==, ==, !=, <, <=, >, and >=.
  • Logical expressions: &&, ||, ??, and !.
  • Membership: status in ['open', 'pending'] checks strings, arrays, and object keys.
  • Conditional values: condition ? yes : no.
  • Optional chaining: user?.profile?.name.

Arrays, Objects, and Templates

Wrapped expressions preserve typed values, so arrays and objects can be sent directly to actions.

Safe Calls

Only whitelisted global helpers can be called from expressions.

  • Type helpers: String(value), Number(value), and Boolean(value).
  • Array helper: Array.isArray(value).
  • Math helpers: Math.abs, Math.ceil, Math.floor, Math.max, Math.min, Math.round, and Math.trunc.

Bindings

Writable form bindings use the $ reference form. A typed expression can read a state field, but it does not create a writable control binding.

XML Escaping

XML attributes must still be valid XML. Escape reserved characters before the expression reaches the LongLink evaluator.

  • Use &lt; for less-than comparisons.
  • Use &amp;&amp; for logical and.
  • Quote XML attributes with single quotes when the expression contains many double quotes.

Unsupported Syntax

Expressions are intentionally read-only and sandboxed.

  • Arbitrary function calls and object method calls are blocked.
  • Assignments, updates, constructors, classes, imports, and dynamic code execution are blocked.
  • Inherited properties and unsafe prototype names are not readable.