struct
TextTemplate
pub struct TextTemplate {
pub parts: Vec<TextPart>,
}A string with {path} interpolations.
Fields
Methods
as_literal
pub fn as_literal(&self) -> Option<String>A template that is just literal text. The text, when it's all literal (no interpolations).
parse
pub fn parse(raw: &str) -> Result<TextTemplate, String>Parse raw string contents: process escapes (\" \\ \n \t \{ \}), treat {{ / }} as literal braces, and split out {path} interpolations.
as_static
pub fn as_static(&self) -> Option<String>The literal text, if the template has no interpolations.
references
pub fn references(&self) -> Vec<&Path>Every interpolated plain path, in order (see [TextTemplate::collect_references] for expressions too).
collect_references
pub fn collect_references(&self, bound: &mut Vec<String>, out: &mut BTreeSet<String>)Every name the interpolations read, bound names excluded.
render
pub fn render(&self, lookup: impl Fn(&Path) -> String) -> StringProduce the final string, resolving references with lookup. Expression interpolations print as written.