Implement the contextDump helper.

master
Tom Alexander 4 years ago
parent 648ae5dfdb
commit 92c65a109b
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE

@ -765,8 +765,41 @@ impl<'a> DustRenderer<'a> {
}
}
DustTag::DTHelperContextDump(parameterized_block) => {
//todo
todo!()
let param_map =
ParametersContext::new(self, breadcrumbs, &parameterized_block.params, None);
let value = self.tap(breadcrumbs, &param_map, "key");
let destination = self.tap(breadcrumbs, &param_map, "to");
let value_rendered = match value.as_ref().map(|maybe_ice| {
maybe_ice
.as_ref()
.map(|ice| ice.get_context_element_reference())
.map(|ce| ce.render(&Vec::new()))
}) {
Some(Ok(Ok(val))) => val,
_ => "current".to_owned(),
};
let destination_rendered = match destination.as_ref().map(|maybe_ice| {
maybe_ice
.as_ref()
.map(|ice| ice.get_context_element_reference())
.map(|ce| ce.render(&Vec::new()))
}) {
Some(Ok(Ok(val))) => val,
_ => "output".to_owned(),
};
match (
value_rendered.as_str(),
destination_rendered.as_str(),
breadcrumbs.last(),
) {
("current", "output", None) => return Ok("{}".to_owned()),
("current", "console", None) => println!("{{}}"),
("current", "output", Some(bc)) => return Ok(format!("{:?}", bc)),
("current", "console", Some(bc)) => println!("{:?}", bc),
("full", "output", _) => return Ok(format!("{:?}", breadcrumbs)),
("full", "console", _) => println!("{:?}", breadcrumbs),
_ => panic!("Unhandled contextDump parameters."),
}
}
}

Loading…
Cancel
Save