pub struct Template<'a> { /* private fields */ }Expand description
A parsed string template that borrows the source string.
You can parse the template once and call Self::expand() multiple times.
This is generally more efficient than calling substitute() multiple times on the same string.
This template borrows the source string.
You can use TemplateBuf if you need a template that owns the source string.
If you have a byte slice or vector instead of a string,
you can use ByteTemplate or ByteTemplateBuf.
Implementations§
Source§impl<'a> Template<'a>
impl<'a> Template<'a>
Sourcepub fn from_str(source: &'a str) -> Result<Self, ParseError>
pub fn from_str(source: &'a str) -> Result<Self, ParseError>
Parse a template from a string slice.
The source is can contain variables to be substituted later,
when you call Self::expand().
Variables have the form $NAME, ${NAME} or ${NAME:default}.
A variable name can only consist of ASCII letters, digits and underscores.
They are allowed to start with numbers.
You can escape dollar signs, backslashes, colons and braces with a backslash.