Invoking the compile function.
I am going to have to address the lifetime issue of "compiled" duster templates borrowing the input str.
This commit is contained in:
parent
ce0819e85b
commit
58aba8efd5
@ -12,6 +12,7 @@ pub(crate) enum CustomError {
|
||||
Serde(serde_json::Error),
|
||||
Utf8(Utf8Error),
|
||||
FromUtf8(FromUtf8Error),
|
||||
DusterCompile(duster::renderer::CompileError),
|
||||
}
|
||||
|
||||
impl From<std::io::Error> for CustomError {
|
||||
@ -67,3 +68,9 @@ impl From<FromUtf8Error> for CustomError {
|
||||
CustomError::FromUtf8(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<duster::renderer::CompileError> for CustomError {
|
||||
fn from(value: duster::renderer::CompileError) -> Self {
|
||||
CustomError::DusterCompile(value)
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,5 @@
|
||||
use crate::error::CustomError;
|
||||
|
||||
use super::renderer_integration::RendererIntegration;
|
||||
use duster::renderer::DustRenderer;
|
||||
use serde::Serialize;
|
||||
@ -11,15 +13,16 @@ impl DusterRenderer {
|
||||
}
|
||||
|
||||
impl RendererIntegration for DusterRenderer {
|
||||
fn load_template<N, C>(&mut self, name: N, contents: C) -> Result<(), crate::error::CustomError>
|
||||
fn load_template<N, C>(&mut self, name: N, contents: C) -> Result<(), CustomError>
|
||||
where
|
||||
N: Into<String>,
|
||||
C: Into<String>,
|
||||
C: AsRef<str>,
|
||||
{
|
||||
let compiled_template = duster::renderer::compile_template(contents.as_ref())?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn render<C>(&self, context: C) -> Result<String, crate::error::CustomError>
|
||||
fn render<C>(&self, context: C) -> Result<String, CustomError>
|
||||
where
|
||||
C: Serialize,
|
||||
{
|
||||
|
@ -6,9 +6,9 @@ pub(crate) trait RendererIntegration {
|
||||
fn load_template<N, C>(&mut self, name: N, contents: C) -> Result<(), CustomError>
|
||||
where
|
||||
N: Into<String>,
|
||||
C: Into<String>;
|
||||
C: AsRef<str>;
|
||||
|
||||
fn render<C>(&self, context: C) -> Result<String, crate::error::CustomError>
|
||||
fn render<C>(&self, context: C) -> Result<String, CustomError>
|
||||
where
|
||||
C: Serialize;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user