Variables
Value variables — reusable values referenced with @.
A value variable is a reusable value defined in the header with an @-prefixed key and used anywhere a value is expected by writing @name. Variables reduce repetition, shrink payloads, and let you keep sensitive values in one place.
@is for values. For reusable schemas and types, use$references — see Schema References.
Defining and using
~ @active: T
~ $schema: { name: string, isActive: bool }
---
~ John, @active
~ Jane, @activeIn schema constraints
A variable can supply a constraint value, such as a choices list:
~ @r: red
~ @g: green
~ @b: blue
~ $schema: { name: string, color: { string, choices: [@r, @g, @b] } }
---
~ John, redUse cases
Reduce size and repetition
Define a value once and reference it many times:
Keep sensitive values together
Variables let you isolate secrets/keys in the header instead of scattering them through the data:
See Also
Last updated
Was this helpful?
