Trait TemplateRenderer

Source
pub trait TemplateRenderer:
    Send
    + Sync
    + Debug {
    // Required methods
    fn render(&self, template: &str, context: &Value) -> Result<String>;
    fn validate(&self, template: &str, context: &Value) -> Result<()>;
}
Expand description

Trait for template rendering implementations.

This trait defines methods for rendering and validating templates.

Required Methods§

Source

fn render(&self, template: &str, context: &Value) -> Result<String>

Renders a template with the specified context.

§Arguments
  • template - The template name or identifier.
  • context - The context data for rendering the template.
§Returns
  • Result<String> - The rendered output, or an error if rendering fails.
Source

fn validate(&self, template: &str, context: &Value) -> Result<()>

Validates the template against the context.

§Arguments
  • template - The template name or identifier.
  • context - The context data.
§Returns
  • Result<()> - Indicates success if valid, or an error otherwise.

Implementors§