mirror of
https://github.com/askama-rs/askama.git
synced 2025-10-02 15:25:19 +00:00
added trim filter (#18)
This commit is contained in:
parent
7362ca0dcb
commit
6f9fc729eb
@ -79,6 +79,12 @@ pub fn uppercase(s: &fmt::Display) -> String {
|
||||
upper(s)
|
||||
}
|
||||
|
||||
/// Strip leading and trailing whitespace.
|
||||
pub fn trim(s: &fmt::Display) -> String {
|
||||
let s = format!("{}", s);
|
||||
s.trim().to_owned()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
@ -99,4 +105,9 @@ mod tests {
|
||||
assert_eq!(upper(&"FooBar"), "FOOBAR");
|
||||
assert_eq!(upper(&"foo"), "FOO");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_trim() {
|
||||
assert_eq!(trim(&" Hello\tworld\t"), "Hello\tworld");
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user