Environment Properties (@env)¶
Normative reference
This page is a guide. The normative definition of every built-in @env property — value kind,
sourcing, and worked examples — lives in the Bars specification's
Environment Properties reference.
Beyond the rendered context, a render carries properties — values that are not part of the data
being rendered. Templates read them with the @env namespace:
{{ @env/now }}looks up the property namednow.{{ @env/foo/bar }}looks upfooand, when its value wraps a container element, resolves the RFC 6901 sub-pointer/baragainst it.- Dot notation works too:
{{ @env.foo }}and{{ @env.foo.bar }}.
An unresolved @env reference — an unknown property name, or a sub-pointer applied to a value that
is not a container — renders as empty (not the literal "null" interpolation falls back to for an
absent context lookup). Which properties exist beyond the built-in one below is configured by
whoever builds the application you're writing templates for — see
Environment Properties if that's you.
The default now property¶
Every render includes one default property, now, holding the date-time the render started. It
flows straight into the date-time transforms:
@env vs. @local¶
@env properties are render-global: they are visible from anywhere in a render, including
inside every {{#each}} iteration and {{#with}} block, and are set once for the whole render (or
via {{= @env/name = … }} for the render-scoped shadowing case — see
Scoped Variables). Contrast with @local, which is bound and read entirely
within the template via {{= }} and scoped to the current context frame.
Where to next¶
- Scoped Variables —
{{= @env/name = … }}and{{= @local/name = … }}. - Date/Time Transforms — the transforms
@env/nowfeeds directly. - Interpolation — how
@env/namefits among the other identifier forms.