@let

Declares named constants, read back with {{name}}.

On this page

#Examples

@let(source-note: Johnson & Raven (1973))

As reported in {{source-note}}.
@let(
    plants: 240
    site: Baltra
)
@let(per-day: {{plants / 8}})

We surveyed {{plants}} plants on {{site}}, {{per-day}} a day.

#Notes

  • The attribute group is the bindings, so @let has no attributes and no implicit value of its own: @let takes no implicit attribute — its attribute group holds the author's bindings.
  • A constant is visible after its @let, inside the construct that holds it. Read before it, it is undefined constant k.
  • A key declared again in the same scope replaces the earlier value. One declared in a scene hides the document's inside that scene.
  • The bindings of one group cannot read each other; a constant computed from another goes in a later @let.
  • A bare key is true: @let(answers).
  • body and detail are reserved, because a @define template uses them for its sections: body is a reserved constant name.
  • A value's text takes the type of the position it lands in, and never adds structure: a value beginning - on a line of its own is a paragraph, not a list item.
  • A constant can be applied with ->: @let(parties: (DEM: blue; otherwise: grey)), then colour: #d.party -> parties.
  • A constant may hold a bound value such as {{#f.slope}}; a position that refuses bound values refuses it where the constant is used.
  • A table of values is a @data dataset, not a constant.

#Writing guidance

  • Source style — The conventions that keep a .chalk file legible to the next person editing it by hand.

Last updated