Skip to content

Functions

Leonard Ramminger edited this page May 14, 2026 · 1 revision

Functions

Native Template Functions

{{ fn greet(name) }}Hello {{ name }}{{ endfn }}
{{ greet("Ada") }}

Behavior:

  1. definition emits no output
  2. return value is rendered text string
  3. available only after definition point

Lua Functions

{{ fn users() lua:block }}
return { { name = "Ada" }, { name = "Grace" } }
{{ endfn }}

Behavior:

  1. return type can be scalar, list, object, bool, number, or null
  2. usable in if, set, interpolation, and for

Scope Rules

  1. function defined in file is visible from that point onward
  2. later includes from that point can use it
  3. function defined inside include stays local to that include

Errors

  1. call before definition fails
  2. wrong arity fails
  3. unknown function fails
  4. native template function cannot act as iterable for for

Clone this wiki locally