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:
parent
869c32df21
commit
542c2c4536
@ -7,6 +7,7 @@ pub use node_invoker::run_node_dust;
|
|||||||
pub use node_invoker::NodeError;
|
pub use node_invoker::NodeError;
|
||||||
pub use node_invoker::Result;
|
pub use node_invoker::Result;
|
||||||
pub use parser::template;
|
pub use parser::template;
|
||||||
|
pub use parser::Body;
|
||||||
pub use parser::DustTag;
|
pub use parser::DustTag;
|
||||||
pub use parser::Template;
|
pub use parser::Template;
|
||||||
pub use parser::TemplateElement;
|
pub use parser::TemplateElement;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
use crate::parser::template;
|
use crate::parser::template;
|
||||||
|
use crate::parser::Body;
|
||||||
use crate::parser::DustTag;
|
use crate::parser::DustTag;
|
||||||
use crate::parser::Template;
|
use crate::parser::Template;
|
||||||
use crate::parser::TemplateElement;
|
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
|
where
|
||||||
C: ContextElement,
|
C: ContextElement,
|
||||||
{
|
{
|
||||||
let mut output = String::new();
|
let mut output = String::new();
|
||||||
for elem in &template.contents.elements {
|
for elem in &body.elements {
|
||||||
match elem {
|
match elem {
|
||||||
TemplateElement::TESpan(span) => output.push_str(span.contents),
|
TemplateElement::TESpan(span) => output.push_str(span.contents),
|
||||||
TemplateElement::TETag(dt) => {
|
TemplateElement::TETag(dt) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user