prosaic_template!() { /* proc-macro */ }Expand description
Compile-time-validated template string.
Parses the template, checks every slot reference against the declared
slots list, and checks every pipe name against the engine’s known-pipe
set. On success, expands to the original template string literal (&'static str).
On mismatch, emits a compile error pointing at the template: argument.
When context: <Type> is provided, the macro also emits const assertions
at compile time, verifying that each slot’s required type (inferred from its
pipe chain) is compatible with the corresponding field in <Type>’s
HasProsaicSchema implementation. A missing slot or type mismatch is a
hard compile error with a clear message identifying the slot and context type.
§Syntax
use prosaic_derive::prosaic_template;
let tpl: &'static str = prosaic_template! {
template: "The {entity_type} {name|refer} was renamed to {new_name}",
slots: [entity_type, name, new_name],
};
assert!(tpl.contains("{name|refer}"));The slots: list uses bare identifiers matching the slot keys in the
template. Declaring extra slots that are not used in the template is
allowed. Slots used by conditional guards ({?key}) must also be declared.
§Limitations (v1)
- Pipe arguments (
truncate:3,verb:past, etc.) are not validated — only the pipe name. - Slots inside partial inclusions (
{>name}) are not validated — partials are opaque at compile time and resolved by the engine at registration time. - Compile-fail tests require an external
trybuildharness (deferred to v2).