From: Andrea Zagli Date: Fri, 10 May 2024 10:14:45 +0000 (+0200) Subject: Added field filters lowercase and capitalcase. X-Git-Url: https://saetta.ns0.it/gitweb?a=commitdiff_plain;h=daa1228924a789b6d2930f71f9cffe52c21af388;p=rust%2Fzakform Added field filters lowercase and capitalcase. --- diff --git a/Cargo.lock b/Cargo.lock index d156120..1691129 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -761,6 +761,12 @@ dependencies = [ "ahash 0.7.6", ] +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + [[package]] name = "http" version = "0.2.9" @@ -1925,6 +1931,7 @@ dependencies = [ "chrono", "config", "gettext", + "heck", "lazy_static", "regex", "serde", diff --git a/Cargo.toml b/Cargo.toml index 5919400..1b16c91 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,6 +14,7 @@ chrono = { version = "0.4" } lazy_static = "1.4.0" gettext = "0.4.0" regex = "1.5" +heck = "0.5" [dev-dependencies] config = "0.13" diff --git a/src/filters.rs b/src/filters.rs index e6e628f..68f66f4 100644 --- a/src/filters.rs +++ b/src/filters.rs @@ -1,3 +1,5 @@ +use heck::ToTitleCase; + pub type Filter = fn(value: &String) -> String; pub fn filter_trim(value: &String) -> String { @@ -7,3 +9,11 @@ pub fn filter_trim(value: &String) -> String { pub fn filter_uppercase(value: &String) -> String { value.to_uppercase() } + +pub fn filter_lowercase(value: &String) -> String { + value.to_lowercase() +} + +pub fn filter_capitalcase(value: &String) -> String { + value.to_title_case() +}