Skip to main content

Module template

Module template 

Source
Expand description

String substitution for path templates and message templates.

Two variants, distinguished by delimiter style:

  • Path templates — single braces, fixed token set derived from a matched file’s relative path. Example: "{dir}/{stem}.h".
  • Message templates — double braces, namespaced lookups for rule messages and similar user-facing strings. Example: "{{ctx.primary}} has no matching header at {{ctx.partner}}".

Both are intentionally small and self-contained: no regex dependency, no dynamic parser. Unknown tokens are preserved literally so a typo surfaces in output rather than silently blanking out.

Structs§

PathTokens
Token values derived from a relative path. Consumed by render_path and by cross-file rules to resolve partner paths.

Functions§

render_mapping
Substitute {{namespace.key}} placeholders in a message template. The caller-supplied resolve closure returns the substituted value, or None to leave the placeholder literal.
render_message
render_path
Substitute {token} placeholders in a path-shaped template. Unknown tokens are preserved literally (so "{unknown}" renders as "{unknown}").
render_paths_spec
Apply path-template substitution to every pattern in a PathsSpec.
render_value
Recursive mate to render_mapping for arbitrary YAML values.