Wit

Interpolation & captures

Wit has three ways to drop a value into place, and each is live in one context:

  • ::name:: and ::body:: — inside a definition body; carry rich content.
  • @name.field — in prose and parameter values; inserts the value.
  • {{path}} — inside a raw @@name body; inserts plain text.

Captures carry rich content

A parameter or body inserted with ::name:: / ::body:: keeps its markup — emphasis, lists, headings, several paragraphs.

source
#panel(heading)
@section
(h3 ::heading:: h3)
::body::
section@
panel#

@panel(heading: What to _pack_):
@ul
(li Waterproofs li)
(li A head torch li)
ul@
!!
result

What to pack

  • Waterproofs
  • A head torch
<section><h3>What to <em>pack</em></h3><ul><li>Waterproofs</li><li>A head torch</li></ul></section>

A one-paragraph value used inline splices into the sentence; a multi-block value becomes blocks. A parameter marked literal in the header is inserted exactly as written instead (see Parameters).

Data into prose

Outside a definition, ::name:: renders an unresolved marker. Put data into a sentence with a dotted path:

source
#tour: { city: Lisbon, days: 5 } !!

The tour spends @tour.days days in @tour.city.
result

The tour spends 5 days in Lisbon.

That renders The tour spends 5 days in Lisbon.

Interpolation in raw bodies

{{path}} is live only inside a raw @@name … name@@ body, where Wit syntax is otherwise inert — which makes it the tool for stylesheets driven by data.

source
#theme: { accent: teal, radius: 6 } !!

@@style
.badge { color: {{theme.accent}}; border-radius: {{theme.radius}}px; }
style@@
result
<style>.badge { color: teal; border-radius: 6px; }</style>

The path may name a field or a single-value definition (#accent: teal !! then {{accent}}). Numbers and booleans become their text; a whole record or list is E_UNRESOLVED_REFERENCE. In prose and in a frozen @@@name body, {{…}} stays literal text.

Common mistakes

  • Writing {{tour.city}} in a paragraph — it prints as typed; use @tour.city.
  • Writing ::item.name:: inside a loop in prose — use @item.name.
  • Interpolating a record into CSS — name the field.

See also

Defining nodes · Data · Literal & raw nodes · Parameters