pub struct Template { /* private fields */ }Available on crate feature
template only.Expand description
A parsed template: a flat sequence of nodes, with $if$/$for$ holding their bodies inline.
Implementations§
Source§impl Template
impl Template
Sourcepub fn parse(source: &str) -> Result<Template, TemplateError>
pub fn parse(source: &str) -> Result<Template, TemplateError>
Parse template source into a tree.
§Errors
TemplateError on an unterminated directive, an unmatched $if$/$for$, a dangling
$endif$/$endfor$/$else$, or an unknown pipe.
Source§impl Template
impl Template
Sourcepub fn render(
&self,
context: &Value,
resolve_partial: &dyn Fn(&str) -> Option<String>,
) -> Result<String, TemplateError>
pub fn render( &self, context: &Value, resolve_partial: &dyn Fn(&str) -> Option<String>, ) -> Result<String, TemplateError>
Render the template against context. resolve_partial maps a partial name to its source
text; pass a closure returning None for templates that use no partials.
§Errors
TemplateError when a referenced partial cannot be resolved (resolve_partial returns
None for a name the template actually uses).
Trait Implementations§
impl StructuralPartialEq for Template
Auto Trait Implementations§
impl Freeze for Template
impl RefUnwindSafe for Template
impl Send for Template
impl Sync for Template
impl Unpin for Template
impl UnsafeUnpin for Template
impl UnwindSafe for Template
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