Directive

interface Directive

A directive: a declaration of its option names plus a pure body.

A directive is authored as a JSON object with exactly one $-key (the marker); the marker's value is the DirectiveArgs.primary argument, the other keys are options. An authored option key not in options is a loud malformedOption — typos fail, they don't vanish.

The body returns one JSON result; where the directive sits decides how the walker uses it — node position (in children/layout): an array flattens into the surrounding children and JsonNull contributes nothing; value position (everywhere else): the result is the value, verbatim.

Bodies must be pure — no I/O, no clock, no randomness. Time and environment enter as data: the host puts them in state, templates read them like any value.

Properties

Link copied to clipboard
open val options: Set<String>

The declared option names. Anything else on the marker object fails loud.

Functions

Link copied to clipboard
abstract fun body(args: DirectiveArgs, ctx: DirectiveContext): <Error class: unknown class>

Compute this directive's single result. Resolve arguments on demand via ctx.