Turns out I was wrong, the @size helper attempts to cast to a number regardless of the input and it uses that. Fixed the test.

This commit is contained in:
Tom Alexander
2020-06-14 15:20:54 -04:00
parent e70f397545
commit 648ae5dfdb
4 changed files with 30 additions and 32 deletions

View File

@@ -730,17 +730,37 @@ impl<'a> DustRenderer<'a> {
maybe_ice
.as_ref()
.map(|ice| ice.get_context_element_reference())
.map(|ce| ce.get_size())
// .map(|ce| ce.get_size())
});
match value_ce {
// If we found the key but could not get the size from it, render nothing.
Some(Ok(None)) => return Ok("".to_owned()),
// If "key" is not on the @size tag at all, render 0.
None => return Ok("0".to_owned()),
// If the key value could not be found in the context, render 0.
Some(Err(_)) => return Ok("0".to_owned()),
Some(Ok(Some(ce_size))) => {
return ce_size.get_context_element_reference().render(&Vec::new())
Some(Ok(ce)) => {
// The @size helper attempts to cast values to
// numbers, and if that succeeds it uses the
// number, otherwise we'll get the size of the
// original type.
match ce.cast_to_type("number") {
Some(ice) => {
return ice
.get_context_element_reference()
.get_size()
.map(|ce_size| {
ce_size.get_context_element_reference().render(&Vec::new())
})
.unwrap_or(Ok("".to_owned()))
}
None => {
return ce
.get_size()
.map(|ce_size| {
ce_size.get_context_element_reference().render(&Vec::new())
})
.unwrap_or(Ok("".to_owned()))
}
}
}
}
}