Cleanup + Database code

This commit is contained in:
Jai A
2020-06-02 12:03:45 -07:00
parent ab1e31c0e7
commit e03e58323b
4 changed files with 120 additions and 58 deletions

View File

@@ -13,12 +13,16 @@ impl HelperDef for HumanFormatHelper {
_rc: &mut RenderContext<'reg, 'rc>,
out: &mut dyn Output,
) -> HelperResult {
let param = h.param(0).and_then(|v| v.value().as_f64()).unwrap_or(0.0);
let param = h.param(0).and_then(|v| v.value().as_str()).unwrap_or("0.0");
let mut formatted = human_format::Formatter::new().format(param);
formatted.retain(|c| !c.is_whitespace());
if param.len() > 3 {
let mut formatted = human_format::Formatter::new().format(param.parse().unwrap());
formatted.retain(|c| !c.is_whitespace());
out.write(formatted.to_uppercase().as_ref())?;
out.write(formatted.to_uppercase().as_ref())?;
} else {
out.write(param)?;
}
Ok(())
}