# Liquid filter for Rust to commafy a number (put comma after every 3 digtist from right to left) The [liquid](https://crates.io/crates/liquid) crate, the Rust implementation of the [liquid](https://shopify.github.io/liquid/) template system has many filters to manipulate the data in the template, but AFAIK there is no filter to commafy a number. ## Usage: * `Cargo.toml`: ```toml [dependencies] liquid = "0.26" liquid-filter-reverse-string = "0.1" ``` * `src/main.rs`: ```rust use liquid_filter_commafy::Commafy; fn main() { println!("{}", render("{{value | commafy}}", liquid::object!({ "value": "2345" }))); println!("{}", render("{{value | commafy}}", liquid::object!({ "value": 123456 }))); } fn render(tmpl: &str, glob: liquid::Object) -> String { let template = liquid::ParserBuilder::with_stdlib() .filter(Commafy) .build() .unwrap() .parse(tmpl) .unwrap(); template.render(&glob).unwrap() } ``` The important pieces: The `use` statement: ``` use liquid_filter_commafy::Commafy; ``` The use of the `commafy` filter in the template: ``` let template = "{{value | commafy}}"; ``` * adding the filter to the engine: ```rust .filter(Commafy) ``` ## Release * update the `version` number in `Cargo.toml` ``` cargo publish git tag -a v0.1.0 -m v0.1.0 git push --tags ```