pub struct TemplateEngine { /* private fields */ }
Expand description
Holds a set of templates
Implementations§
source§impl TemplateEngine
impl TemplateEngine
pub fn new() -> Self
sourcepub fn add_template<N, S>(&mut self, name: N, source: S) -> Result<(), Error>
pub fn add_template<N, S>(&mut self, name: N, source: S) -> Result<(), Error>
Add a named template with the specified source.
If name ends with .html
then automatical escaping of html entities
will be performed on substitutions.
sourcepub fn get_template(&self, name: &str) -> Result<Template<'_, '_>, Error>
pub fn get_template(&self, name: &str) -> Result<Template<'_, '_>, Error>
Get a reference to a named template
sourcepub fn add_global<N, V>(&mut self, name: N, value: V)
pub fn add_global<N, V>(&mut self, name: N, value: V)
Define a global value that can be reference by all templates
pub fn render<CTX>(
&self,
name: &str,
source: &str,
context: CTX,
) -> Result<String, Error>where
CTX: Serialize,
Auto Trait Implementations§
impl !Freeze for TemplateEngine
impl !RefUnwindSafe for TemplateEngine
impl Send for TemplateEngine
impl Sync for TemplateEngine
impl Unpin for TemplateEngine
impl !UnwindSafe for TemplateEngine
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