Templating

Variables, expressions, and Liquid filters inside strings

Inside strings, use {{}} for interpolation: plain variable paths render via Liquid (with filters), and anything with operators is evaluated as a kaya expression — see the Templating reference for the full rules.

Basic Interpolation

let name = "Alice"
let age = 30

// Basic interpolation
"Hello, {{name}}!"
"You are {{age}} years old."

// Property access and indexing
"User: {{user.name}}"
"First item: {{items[0]}}"

// Liquid filters
let formatted = "{{value | json}}"
let upper = "{{name | upcase}}"

Inside Templates

Within Liquid templates:

  • Variable paths and indexing: {{user.name}}, {{items[0]}}
  • Filters: json, upcase, downcase, slug, times, render, default, plus Liquid built-ins like join
  • Tags: {% for %}, {% if %}
  • ✅ Kaya expressions — {{age + 1}}, {{n > 5 ? "big" : "small"}}, {{user.first ?? "friend"}} evaluate with normal expression semantics
  • ❌ No function calls — {{calculate(a, b)}} is rejected (templates render synchronously). Compute first, then interpolate:
let result = calculate(a: a, b: b)
"Total: {{result}}"
  • Referencing an undefined variable throws at render time; the sanctioned forms for possibly-missing variables are {% if maybeVar %}…{% endif %} and {{ maybeVar | default: "fallback" }}

Outside Templates

In Kaya expressions:

  • Use direct access: user.name
  • No double braces needed
  • Full expression support

Next Steps