Skip to main content

TemplateEngine

Trait TemplateEngine 

Source
pub trait TemplateEngine: Send + Sync {
    // Required methods
    fn render(&self, template: &str, context: &Value) -> Result<String>;
    fn reload(&self) -> Result<()>;

    // Provided method
    fn render_named(&self, name: &str, context: &Value) -> Result<String> { ... }
}

Required Methods§

Source

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

Source

fn reload(&self) -> Result<()>

Provided Methods§

Source

fn render_named(&self, name: &str, context: &Value) -> Result<String>

Render a template by its exact registered name (including any .html.tera / .text.tera suffix), bypassing the .html.tera suffix that render appends. Used e.g. to render a mailer’s text part. The default delegates to render for engines that do not distinguish variants.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§