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.
This commit is contained in:
Tom Alexander
2020-04-11 23:03:07 -04:00
parent 869c32df21
commit 542c2c4536
2 changed files with 5 additions and 3 deletions

View File

@@ -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<C>(&self, template: &Template, context: &C) -> Result<String, RenderError>
fn render_body<C>(&self, body: &Body, context: &C) -> Result<String, RenderError>
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) => {