Start of structure for extracting inline partials from a template.
This commit is contained in:
parent
12d8b58961
commit
97e806a968
33
src/renderer/inline_partial_tree.rs
Normal file
33
src/renderer/inline_partial_tree.rs
Normal file
@ -0,0 +1,33 @@
|
||||
use crate::parser::Body;
|
||||
use crate::parser::Template;
|
||||
use std::collections::HashMap;
|
||||
|
||||
struct InlinePartialTreeElement<'a> {
|
||||
parent: Option<&'a InlinePartialTreeElement<'a>>,
|
||||
blocks: HashMap<&'a str, &'a Option<Body<'a>>>,
|
||||
}
|
||||
|
||||
impl<'a> InlinePartialTreeElement<'a> {
|
||||
pub fn new(parent: Option<&'a InlinePartialTreeElement<'a>>) -> InlinePartialTreeElement<'a> {
|
||||
InlinePartialTreeElement {
|
||||
parent: parent,
|
||||
blocks: HashMap::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn extract_inline_partials<'a>(
|
||||
template: &'a Template<'a>,
|
||||
) -> HashMap<&'a str, &'a Option<Body<'a>>> {
|
||||
let mut blocks: HashMap<&'a str, &'a Option<Body<'a>>> = HashMap::new();
|
||||
|
||||
extract_inline_partials_from_body(&mut blocks, &template.contents);
|
||||
|
||||
blocks
|
||||
}
|
||||
|
||||
fn extract_inline_partials_from_body<'a, 'b>(
|
||||
blocks: &'b mut HashMap<&'a str, &'a Option<Body<'a>>>,
|
||||
body: &'a Body<'a>,
|
||||
) {
|
||||
}
|
@ -2,6 +2,7 @@
|
||||
|
||||
mod context_element;
|
||||
mod errors;
|
||||
mod inline_partial_tree;
|
||||
mod parameters_context;
|
||||
mod renderer;
|
||||
mod walking;
|
||||
|
Loading…
x
Reference in New Issue
Block a user