diff --git a/src/parser/parser.rs b/src/parser/parser.rs index 9422a6d..768ec88 100644 --- a/src/parser/parser.rs +++ b/src/parser/parser.rs @@ -100,8 +100,8 @@ pub struct Container<'a> { #[derive(Clone, Debug, PartialEq)] pub struct NamedBlock<'a> { - name: &'a str, - contents: Option>, + pub name: &'a str, + pub contents: Option>, } #[derive(Clone, Debug, PartialEq)] diff --git a/src/renderer/inline_partial_tree.rs b/src/renderer/inline_partial_tree.rs index 7c74c3f..f436552 100644 --- a/src/renderer/inline_partial_tree.rs +++ b/src/renderer/inline_partial_tree.rs @@ -10,10 +10,13 @@ struct InlinePartialTreeElement<'a> { } impl<'a> InlinePartialTreeElement<'a> { - pub fn new(parent: Option<&'a InlinePartialTreeElement<'a>>) -> InlinePartialTreeElement<'a> { + pub fn new( + parent: Option<&'a InlinePartialTreeElement<'a>>, + blocks: HashMap<&'a str, &'a Option>>, + ) -> InlinePartialTreeElement<'a> { InlinePartialTreeElement { parent: parent, - blocks: HashMap::new(), + blocks: blocks, } } } @@ -49,6 +52,43 @@ fn extract_inline_partials_from_tag<'a, 'b>( ) { match tag { DustTag::DTComment(..) => (), + DustTag::DTSpecial(..) => (), + DustTag::DTReference(..) => (), + DustTag::DTSection(container) => { + match &container.contents { + None => (), + Some(body) => extract_inline_partials_from_body(blocks, &body), + }; + match &container.else_contents { + None => (), + Some(body) => extract_inline_partials_from_body(blocks, &body), + }; + } + DustTag::DTExists(container) => { + match &container.contents { + None => (), + Some(body) => extract_inline_partials_from_body(blocks, &body), + }; + match &container.else_contents { + None => (), + Some(body) => extract_inline_partials_from_body(blocks, &body), + }; + } + DustTag::DTNotExists(container) => { + match &container.contents { + None => (), + Some(body) => extract_inline_partials_from_body(blocks, &body), + }; + match &container.else_contents { + None => (), + Some(body) => extract_inline_partials_from_body(blocks, &body), + }; + } + DustTag::DTPartial(..) => (), + DustTag::DTInlinePartial(named_block) => { + blocks.insert(&named_block.name, &named_block.contents); + } + DustTag::DTBlock(..) => (), _ => (), // TODO: Implement the rest } } diff --git a/src/renderer/renderer.rs b/src/renderer/renderer.rs index 5a4f18e..6cd6cb6 100644 --- a/src/renderer/renderer.rs +++ b/src/renderer/renderer.rs @@ -183,6 +183,13 @@ impl<'a> DustRenderer<'a> { return Ok(rendered_content); } } + DustTag::DTInlinePartial(named_block) => { + // Inline partials are blank during rendering (they get injected into blocks) + return Ok("".to_owned()); + } + DustTag::DTBlock(named_block) => { + // TODO: Implement + } _ => (), // TODO: Implement the rest } Ok("".to_owned())