You've already forked AstralRinth
forked from didirus/AstralRinth
Curseforge Indexer
This commit is contained in:
18
src/helpers/format_human.rs
Normal file
18
src/helpers/format_human.rs
Normal file
@@ -0,0 +1,18 @@
|
||||
extern crate human_format;
|
||||
use handlebars::*;
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
pub struct HumanFormatHelper;
|
||||
|
||||
impl HelperDef for HumanFormatHelper {
|
||||
fn call<'reg: 'rc, 'rc>(&self, h: &Helper<'reg, 'rc>, r: &'reg Handlebars<'_>, ctx: &'rc Context, 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 mut formatted = human_format::Formatter::new().format(param);
|
||||
formatted.retain(|c| !c.is_whitespace());
|
||||
|
||||
out.write(formatted.to_uppercase().as_ref())?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user