Basic structure for the new tree renderer.
This commit is contained in:
parent
65445cc8fc
commit
ff27c2c85d
@ -7,6 +7,7 @@ mod inline_partial_tree;
|
||||
mod iteration_context;
|
||||
mod parameters_context;
|
||||
mod renderer;
|
||||
mod tree_renderer;
|
||||
mod tree_walking;
|
||||
mod walking;
|
||||
|
||||
|
35
src/renderer/tree_renderer.rs
Normal file
35
src/renderer/tree_renderer.rs
Normal 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(),
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user