Rendering spans

This commit is contained in:
Tom Alexander
2020-04-11 18:25:48 -04:00
parent 13934e8699
commit 2459d7b418
6 changed files with 114 additions and 21 deletions

View File

@@ -30,16 +30,27 @@ fn main() {
.iter()
.map(|(p, contents)| template_from_file(p, contents))
.collect();
let mut dust_context = DustRenderer::new();
let mut dust_renderer = DustRenderer::new();
compiled_templates.iter().for_each(|template| {
dust_context.load_source(template);
dust_renderer.load_source(template);
});
let main_template_name = &compiled_templates
.first()
.expect("There should be more than 1 template")
.name;
println!(
"{}",
dust_renderer
.render(main_template_name, context)
.expect("Failed to render")
);
}
fn template_from_file<'a>(file_path: &str, file_contents: &'a str) -> CompiledTemplate<'a> {
let path: &Path = Path::new(file_path);
let name = path.file_stem().unwrap();
compile_template(file_contents, name.to_string_lossy().to_string())
.expect("Failed to compile template")
}
fn read_context_from_stdin() -> serde_json::map::Map<String, serde_json::Value> {