diff options
author | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2017-02-13 21:36:52 +0100 |
---|---|---|
committer | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2017-02-13 21:36:52 +0100 |
commit | 66a1a06df12367260343da43aadcb7807c812ac2 (patch) | |
tree | 0e3a08589f3b0ca7a1492d1c107bd20818f446cf | |
parent | ef8b20e341ddf94bfbfb2d47c07740d799b4d8ae (diff) | |
download | askama-66a1a06df12367260343da43aadcb7807c812ac2.tar.gz askama-66a1a06df12367260343da43aadcb7807c812ac2.tar.bz2 askama-66a1a06df12367260343da43aadcb7807c812ac2.zip |
Rename filter e to escape, keep e as alias
Diffstat (limited to '')
-rw-r--r-- | askama/src/filters.rs | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/askama/src/filters.rs b/askama/src/filters.rs index fd8222c..17d25c5 100644 --- a/askama/src/filters.rs +++ b/askama/src/filters.rs @@ -4,7 +4,7 @@ fn escapable(b: &u8) -> bool { *b == b'<' || *b == b'>' || *b == b'&' } -pub fn e(s: &fmt::Display) -> String { +pub fn escape(s: &fmt::Display) -> String { let s = format!("{}", s); let mut found = Vec::new(); for (i, b) in s.as_bytes().iter().enumerate() { @@ -39,14 +39,18 @@ pub fn e(s: &fmt::Display) -> String { String::from_utf8(res).unwrap() } +pub fn e(s: &fmt::Display) -> String { + escape(s) +} + #[cfg(test)] mod tests { - use super::e; + use super::*; #[test] fn test_escape() { - assert_eq!(e(&""), ""); - assert_eq!(e(&"<&>"), "<&>"); - assert_eq!(e(&"bla&"), "bla&"); - assert_eq!(e(&"<foo"), "<foo"); + assert_eq!(escape(&""), ""); + assert_eq!(escape(&"<&>"), "<&>"); + assert_eq!(escape(&"bla&"), "bla&"); + assert_eq!(escape(&"<foo"), "<foo"); } } |