From ae74ce411ade9d030dcbe0dd917c459c85f4dc81 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Sat, 9 May 2020 21:09:46 -0400 Subject: [PATCH] Getting down to the extract_inline_partials_from_tag function. --- src/renderer/inline_partial_tree.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/renderer/inline_partial_tree.rs b/src/renderer/inline_partial_tree.rs index bf328c6..7c74c3f 100644 --- a/src/renderer/inline_partial_tree.rs +++ b/src/renderer/inline_partial_tree.rs @@ -1,5 +1,7 @@ use crate::parser::Body; +use crate::parser::DustTag; use crate::parser::Template; +use crate::parser::TemplateElement; use std::collections::HashMap; struct InlinePartialTreeElement<'a> { @@ -30,4 +32,23 @@ fn extract_inline_partials_from_body<'a, 'b>( blocks: &'b mut HashMap<&'a str, &'a Option>>, body: &'a Body<'a>, ) { + for elem in &body.elements { + match elem { + TemplateElement::TEIgnoredWhitespace(_) => (), + TemplateElement::TESpan(span) => (), + TemplateElement::TETag(dt) => { + extract_inline_partials_from_tag(blocks, dt); + } + } + } +} + +fn extract_inline_partials_from_tag<'a, 'b>( + blocks: &'b mut HashMap<&'a str, &'a Option>>, + tag: &'a DustTag, +) { + match tag { + DustTag::DTComment(..) => (), + _ => (), // TODO: Implement the rest + } }