aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2017-02-13 21:36:52 +0100
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2017-02-13 21:36:52 +0100
commit66a1a06df12367260343da43aadcb7807c812ac2 (patch)
tree0e3a08589f3b0ca7a1492d1c107bd20818f446cf
parentef8b20e341ddf94bfbfb2d47c07740d799b4d8ae (diff)
downloadaskama-66a1a06df12367260343da43aadcb7807c812ac2.tar.gz
askama-66a1a06df12367260343da43aadcb7807c812ac2.tar.bz2
askama-66a1a06df12367260343da43aadcb7807c812ac2.zip
Rename filter e to escape, keep e as alias
-rw-r--r--askama/src/filters.rs16
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(&"<&>"), "&lt;&amp;&gt;");
- assert_eq!(e(&"bla&"), "bla&amp;");
- assert_eq!(e(&"<foo"), "&lt;foo");
+ assert_eq!(escape(&""), "");
+ assert_eq!(escape(&"<&>"), "&lt;&amp;&gt;");
+ assert_eq!(escape(&"bla&"), "bla&amp;");
+ assert_eq!(escape(&"<foo"), "&lt;foo");
}
}