pub struct TemplateEngine { /* private fields */ }Expand description
Template engine for rendering templates with variable substitution
Implementations§
Source§impl TemplateEngine
impl TemplateEngine
Sourcepub fn with_resolver(resolver: PlaceholderResolver) -> Self
pub fn with_resolver(resolver: PlaceholderResolver) -> Self
Create a new template engine with custom resolver
Sourcepub fn add_value(&mut self, name: impl Into<String>, value: impl Into<String>)
pub fn add_value(&mut self, name: impl Into<String>, value: impl Into<String>)
Add a value for placeholder substitution
Sourcepub fn add_values(&mut self, values: HashMap<String, String>)
pub fn add_values(&mut self, values: HashMap<String, String>)
Add multiple values at once
Sourcepub fn render(
&self,
template_content: &str,
context: &TemplateContext,
) -> Result<RenderResult, TemplateError>
pub fn render( &self, template_content: &str, context: &TemplateContext, ) -> Result<RenderResult, TemplateError>
Sourcepub fn render_simple(
&self,
template_content: &str,
) -> Result<String, TemplateError>
pub fn render_simple( &self, template_content: &str, ) -> Result<String, TemplateError>
Render a template string directly with simple variable substitution
This is a simpler alternative to the full render method that just does basic placeholder substitution without parsing complex template syntax.
Trait Implementations§
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