Implement the contextDump helper.
This commit is contained in:
parent
648ae5dfdb
commit
92c65a109b
@ -765,8 +765,41 @@ impl<'a> DustRenderer<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
DustTag::DTHelperContextDump(parameterized_block) => {
|
DustTag::DTHelperContextDump(parameterized_block) => {
|
||||||
//todo
|
let param_map =
|
||||||
todo!()
|
ParametersContext::new(self, breadcrumbs, ¶meterized_block.params, None);
|
||||||
|
let value = self.tap(breadcrumbs, ¶m_map, "key");
|
||||||
|
let destination = self.tap(breadcrumbs, ¶m_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…
x
Reference in New Issue
Block a user