pub struct TemplateEngine { /* private fields */ }Expand description
Template engine wrapper around Tera.
Implementations§
Source§impl TemplateEngine
impl TemplateEngine
Sourcepub fn new(project_root: Option<&Path>) -> Result<Self>
pub fn new(project_root: Option<&Path>) -> Result<Self>
Create a new template engine.
Loads all templates (built-in and user overrides) and compiles them.
Sourcepub fn render<T: Serialize>(
&self,
template_id: TemplateId,
context: &T,
) -> Result<String>
pub fn render<T: Serialize>( &self, template_id: TemplateId, context: &T, ) -> Result<String>
Render a template with the given context.
Sourcepub fn is_overridden(&self, template_id: TemplateId) -> bool
pub fn is_overridden(&self, template_id: TemplateId) -> bool
Check if a template is overridden by user.
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