duckweb_tpl

scalar · LOAD duckweb

duckweb_tpl(VARCHAR, ANY) -> VARCHAR

Fills {{name}} placeholders in a template from a struct.

duckweb_tpl(
  (SELECT t.body FROM templates t WHERE t.name = 'item'),
  {id: m.id, note: duckweb_query(route, 'note'),
   mark: '<svg width="8" height="8"></svg>'})

Each field of the struct is a placeholder name. {{name}} interpolates the value HTML-escaped; {{raw:name}} inserts it verbatim.

Escaping is the default so that forgetting the marker produces a visibly over-escaped page rather than an injection — the failure you can see, not the one you ship.

When something is off

The helper never errors. It degrades in ways you can spot on the page:

Whitespace inside the braces is trimmed, so {{ id }} and {{id}} are the same placeholder, as are {{raw: mark}} and {{raw:mark}}.