pub struct DynamicTemplate { /* private fields */ }Expand description
A parsed {{var}} template with an open set of named variables.
Implementations§
Source§impl DynamicTemplate
impl DynamicTemplate
Sourcepub fn parse(template: &str) -> Self
pub fn parse(template: &str) -> Self
Parse a template string. Parsing is lenient and never fails: malformed
{{ / }} runs and invalid names are kept as literal text.
Sourcepub fn variables(&self) -> BTreeSet<String>
pub fn variables(&self) -> BTreeSet<String>
Return the sorted set of variable names referenced by the template.
Sourcepub fn render<F>(&self, lookup: F) -> Result<String, TemplateError>
pub fn render<F>(&self, lookup: F) -> Result<String, TemplateError>
Render the template, resolving each variable via lookup. A variable
with no value yields TemplateError::MissingVariable.
Trait Implementations§
Source§impl Clone for DynamicTemplate
impl Clone for DynamicTemplate
Source§fn clone(&self) -> DynamicTemplate
fn clone(&self) -> DynamicTemplate
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for DynamicTemplate
impl Debug for DynamicTemplate
impl Eq for DynamicTemplate
Source§impl PartialEq for DynamicTemplate
impl PartialEq for DynamicTemplate
impl StructuralPartialEq for DynamicTemplate
Auto Trait Implementations§
impl Freeze for DynamicTemplate
impl RefUnwindSafe for DynamicTemplate
impl Send for DynamicTemplate
impl Sync for DynamicTemplate
impl Unpin for DynamicTemplate
impl UnsafeUnpin for DynamicTemplate
impl UnwindSafe for DynamicTemplate
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more