pub fn render(template: &str, tokens: &[(&str, &str)]) -> StringExpand description
Expand recognised {TOKEN} placeholders in template from tokens.
Tokens are matched by exact name between a { and the next }. An unknown
token, or a { with no closing }, is copied through unchanged.
ยงExamples
use coding_tools::template::render;
let tokens = [("RESULT", "SUCCESS"), ("CODE", "0")];
assert_eq!(render("{RESULT} (exit {CODE})", &tokens), "SUCCESS (exit 0)");
// Unknown tokens pass through, and replacement text is never re-scanned.
assert_eq!(render("{MISSING}", &[]), "{MISSING}");
assert_eq!(render("{X}", &[("X", "{CODE}")]), "{CODE}");