Implement the new partial type in the renderer.

This commit is contained in:
Tom Alexander
2020-05-17 21:11:55 -04:00
parent 402d8679e2
commit 10c8b25817
3 changed files with 52 additions and 0 deletions

View File

@@ -8,6 +8,7 @@ pub use parser::DustTag;
pub use parser::Filter;
pub use parser::KVPair;
pub use parser::OwnedLiteral;
pub use parser::PartialNameElement;
pub use parser::RValue;
pub use parser::Special;
pub use parser::Template;

View File

@@ -193,6 +193,24 @@ impl From<TemplateElement<'_>> for PartialNameElement {
}
}
impl<'a> From<&'a PartialNameElement> for TemplateElement<'a> {
fn from(original: &'a PartialNameElement) -> Self {
match original {
PartialNameElement::PNSpan { contents } => {
TemplateElement::TESpan(Span { contents: contents })
}
PartialNameElement::PNReference { path, filters } => {
TemplateElement::TETag(DustTag::DTReference(Reference {
path: Path {
keys: path.into_iter().map(|s| s.as_str()).collect(),
},
filters: filters.into_iter().map(|f| f.clone()).collect(),
}))
}
}
}
}
/// Any element significant to dust that isn't plain text
///
/// These elements are always wrapped in curly braces