Basic structure for the new tree renderer.

This commit is contained in:
Tom Alexander 2020-05-31 16:21:13 -04:00
parent 65445cc8fc
commit ff27c2c85d
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
2 changed files with 36 additions and 0 deletions

View File

@ -7,6 +7,7 @@ mod inline_partial_tree;
mod iteration_context; mod iteration_context;
mod parameters_context; mod parameters_context;
mod renderer; mod renderer;
mod tree_renderer;
mod tree_walking; mod tree_walking;
mod walking; mod walking;

View File

@ -0,0 +1,35 @@
use crate::parser::template;
use crate::parser::Template;
use crate::renderer::errors::CompileError;
use std::collections::HashMap;
#[derive(Clone, Debug)]
pub struct CompiledTemplate<'a> {
template: Template<'a>,
pub name: String,
}
#[derive(Clone, Debug)]
pub struct DustRenderer<'a> {
templates: HashMap<String, &'a Template<'a>>,
}
pub fn compile_template<'a>(
source: &'a str,
name: String,
) -> Result<CompiledTemplate<'a>, CompileError> {
// TODO: This could use better error management
let (_remaining, parsed_template) = template(source).expect("Failed to compile template");
Ok(CompiledTemplate {
template: parsed_template,
name: name,
})
}
impl<'a> DustRenderer<'a> {
pub fn new() -> DustRenderer<'a> {
DustRenderer {
templates: HashMap::new(),
}
}
}