Getting rendered output from duster.
This commit is contained in:
@@ -3,7 +3,6 @@ use std::collections::HashMap;
|
||||
use crate::error::CustomError;
|
||||
|
||||
use super::renderer_integration::RendererIntegration;
|
||||
use duster::renderer::DustRenderer;
|
||||
use serde::Serialize;
|
||||
|
||||
pub(crate) struct DusterRenderer<'a> {
|
||||
@@ -29,10 +28,15 @@ impl<'a> RendererIntegration<'a> for DusterRenderer<'a> {
|
||||
where
|
||||
C: Serialize,
|
||||
{
|
||||
let mut dust_renderer = DustRenderer::new();
|
||||
println!("{}", serde_json::to_string(&context)?);
|
||||
|
||||
// TODO
|
||||
Ok("".to_owned())
|
||||
let mut dust_renderer = duster::renderer::DustRenderer::new();
|
||||
for (name, compiled_template) in self.templates.iter() {
|
||||
dust_renderer.load_source(compiled_template, (*name).to_owned());
|
||||
}
|
||||
// TODO: This is horribly inefficient. I am converting from a serialize type to json and back again so I can use the existing implementation of IntoContextElement. Honestly, I probably need to rework a lot of duster now that I've improved in rust over the years.
|
||||
let json_context = serde_json::to_string(&context)?;
|
||||
println!("Context: {}", json_context);
|
||||
let parsed_context: serde_json::Value = serde_json::from_str(json_context.as_str())?;
|
||||
let rendered_output = dust_renderer.render("main", Some(&parsed_context))?;
|
||||
Ok(rendered_output)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user