From 542c2c4536ad31289fa49d4255eb34fc6a4c1937 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Sat, 11 Apr 2020 23:03:07 -0400 Subject: [PATCH] Switching render_template to render_body. The body element is re-used as a child element in blocks, so it makes more sense to make a function that renders that as opposed to a function that renders a top-level-only container that contains only a body. --- src/parser/mod.rs | 1 + src/renderer/renderer.rs | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/parser/mod.rs b/src/parser/mod.rs index c9c748b..193516e 100644 --- a/src/parser/mod.rs +++ b/src/parser/mod.rs @@ -7,6 +7,7 @@ pub use node_invoker::run_node_dust; pub use node_invoker::NodeError; pub use node_invoker::Result; pub use parser::template; +pub use parser::Body; pub use parser::DustTag; pub use parser::Template; pub use parser::TemplateElement; diff --git a/src/renderer/renderer.rs b/src/renderer/renderer.rs index 977c8a3..ac664a8 100644 --- a/src/renderer/renderer.rs +++ b/src/renderer/renderer.rs @@ -1,4 +1,5 @@ use crate::parser::template; +use crate::parser::Body; use crate::parser::DustTag; use crate::parser::Template; use crate::parser::TemplateElement; @@ -58,15 +59,15 @@ impl<'a> DustRenderer<'a> { }); } }; - self.render_template(main_template, context) + self.render_body(&main_template.contents, context) } - fn render_template(&self, template: &Template, context: &C) -> Result + fn render_body(&self, body: &Body, context: &C) -> Result where C: ContextElement, { let mut output = String::new(); - for elem in &template.contents.elements { + for elem in &body.elements { match elem { TemplateElement::TESpan(span) => output.push_str(span.contents), TemplateElement::TETag(dt) => {