pub struct TemplateManager { /* private fields */ }Expand description
Manages template loading, caching, and rendering
Implementations§
Source§impl TemplateManager
impl TemplateManager
Sourcepub fn new<P: AsRef<Path>>(template_dir: P) -> Self
pub fn new<P: AsRef<Path>>(template_dir: P) -> Self
Creates a new TemplateManager with the given template directory
Sourcepub fn default() -> Self
pub fn default() -> Self
Creates a new TemplateManager with default template directory “./template”
Sourcepub fn with_max_cache_size(self, size: usize) -> Self
pub fn with_max_cache_size(self, size: usize) -> Self
Sets the maximum cache size
Sourcepub fn with_caching(self, enabled: bool) -> Self
pub fn with_caching(self, enabled: bool) -> Self
Enables or disables template caching
Sourcepub fn render(
&self,
template_name: &str,
data: &HashMap<String, Obj>,
) -> Result<String, String>
pub fn render( &self, template_name: &str, data: &HashMap<String, Obj>, ) -> Result<String, String>
Loads and renders a template by name
Sourcepub fn render_string(
&self,
template_content: String,
data: &HashMap<String, Obj>,
) -> Result<String, String>
pub fn render_string( &self, template_content: String, data: &HashMap<String, Obj>, ) -> Result<String, String>
Loads and renders a template by string
Sourcepub fn reload_template(&self, template_name: &str) -> Result<(), String>
pub fn reload_template(&self, template_name: &str) -> Result<(), String>
Reloads a template from disk, bypassing the cache
Sourcepub fn clear_cache(&self)
pub fn clear_cache(&self)
Clears the entire template cache
Auto Trait Implementations§
impl Freeze for TemplateManager
impl RefUnwindSafe for TemplateManager
impl Send for TemplateManager
impl Sync for TemplateManager
impl Unpin for TemplateManager
impl UnwindSafe for TemplateManager
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