Trait axum_template::TemplateEngine
source · pub trait TemplateEngine {
type Error: IntoResponse;
// Required method
fn render<S: Serialize>(
&self,
key: &str,
data: S
) -> Result<String, Self::Error>;
}
Expand description
An abstraction over different templating engines
§Implementing custom engines
#[derive(Debug)]
pub struct CustomEngine;
impl TemplateEngine for CustomEngine {
type Error = Infallible;
fn render<S: Serialize>(&self, key: &str, data: S) -> Result<String, Self::Error> {
/* Render your template and return the result */
let result = "Hello world".into();
Ok(result)
}
}
See the full working example
custom_engine.rs
Required Associated Types§
sourcetype Error: IntoResponse
type Error: IntoResponse
Error type returned if the engine is unable to process the data
Required Methods§
Object Safety§
This trait is not object safe.