Skip to content

Environment Properties (@env)

An environment carries properties — a Map<String, KbTransformable> of values that are not part of the data being rendered. Templates read them with the @env namespace (see Environment Properties for the template-facing {{ @env/name }} syntax and the default now property).

The default now property

Every freshly built environment includes one default property, now, holding a kotlin.time.Instant captured when the environment is created. It is a KbTransformable.DateTime, so it flows straight into the date-time transforms.

The capturing clock is configurable (defaulting to Clock.System), which makes now deterministic in tests:

val env = kbEnvironment.create(clock = fixedClock)

Registering properties

Properties are configured with the same builder DSL as transforms, via the parallel addProperty / overrideProperty / removeProperty methods:

val env = kbEnvironment.create {
  addProperty("site", siteValue)    // throws if already registered
  overrideProperty("now", fixedNow) // adds or replaces
  removeProperty("now")             // no-op if absent
}

Where to next