pub struct TemplateEngine { /* private fields */ }Expand description
Compiled template engine with Handlebars.
Implementations§
Source§impl TemplateEngine
impl TemplateEngine
Sourcepub fn render_string(
&self,
template: &str,
context: &TemplateContext,
) -> Result<String>
pub fn render_string( &self, template: &str, context: &TemplateContext, ) -> Result<String>
Render a template string with the given context.
Sourcepub fn render_value(
&self,
template: &str,
context: &TemplateContext,
) -> Result<JsonValue>
pub fn render_value( &self, template: &str, context: &TemplateContext, ) -> Result<JsonValue>
Render a template and preserve the JSON value type.
If the template is a simple variable reference like {{item.field}},
this returns the original JSON value (preserving int/float/bool/string
types). Otherwise, it renders through Handlebars and returns a string.
Sourcepub fn render_properties(
&self,
properties: &JsonValue,
context: &TemplateContext,
) -> Result<HashMap<String, JsonValue>>
pub fn render_properties( &self, properties: &JsonValue, context: &TemplateContext, ) -> Result<HashMap<String, JsonValue>>
Render properties from a JSON value template specification. Each value in the map is treated as a Handlebars template.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for TemplateEngine
impl !UnwindSafe for TemplateEngine
impl Freeze for TemplateEngine
impl Send for TemplateEngine
impl Sync for TemplateEngine
impl Unpin for TemplateEngine
impl UnsafeUnpin 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