Skip to main content

split_template

Function split_template 

Source
pub fn split_template(template: &str) -> Vec<TemplateSegment<'_>>
Expand description

Compile-time string scan splitting a template into literal/placeholder segments (Decision D, message-bundles slice 1 — no new lexer/parser grammar; {name} is resolved by this Rust-side scan during lowering, not parsed as an expression). A { with no matching }, or an empty {}, is just literal text — malformed-placeholder checking is out of scope here. The name is taken verbatim, with no whitespace trimming: { name } is a placeholder literally named " name ", which will never match a params key and so always renders as literal text (PR #872 review) — a real rough edge, left for a future slice rather than guessed at here.

message-bundles slice 3 (#878): if a , appears before the placeholder’s naive (non-nested) closing }, it’s treated as an ICU-dispatch placeholder instead of a plain one — the true close is then found via a quote+depth-aware scan (find_icu_close), since an ICU construct’s arms can themselves contain nested {…} bodies. This is the only change from slice 1/2’s behaviour: a template with no comma inside any {…} is scanned byte-for-byte identically to before.