aboutsummaryrefslogtreecommitdiffstats
path: root/testing/tests/simple.rs
diff options
context:
space:
mode:
authorLibravatar Tuomas Siipola <tuomas@zpl.fi>2020-01-12 00:47:52 +0200
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2020-01-12 08:15:04 +0100
commit80148aa75335563106abae8680197e4adf3eb2eb (patch)
treed2c593be4240b086caa5557c150d3546f467322b /testing/tests/simple.rs
parent100679e69d37355f3683df43e58aab21312ea147 (diff)
downloadaskama-80148aa75335563106abae8680197e4adf3eb2eb.tar.gz
askama-80148aa75335563106abae8680197e4adf3eb2eb.tar.bz2
askama-80148aa75335563106abae8680197e4adf3eb2eb.zip
Support escaping in string literals
Do not attempt to parse escape sequences thoroughly. Instead let the Rust compiler to check the string literals and provide nice error messages if necessary.
Diffstat (limited to 'testing/tests/simple.rs')
-rw-r--r--testing/tests/simple.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/testing/tests/simple.rs b/testing/tests/simple.rs
index 53f1122..a075d26 100644
--- a/testing/tests/simple.rs
+++ b/testing/tests/simple.rs
@@ -122,6 +122,19 @@ fn test_literals() {
assert_eq!(s.render().unwrap(), "a\na\ntrue\nfalse");
}
+#[derive(Template)]
+#[template(path = "literals-escape.html")]
+struct LiteralsEscapeTemplate {}
+
+#[test]
+fn test_literals_escape() {
+ let s = LiteralsEscapeTemplate {};
+ assert_eq!(
+ s.render().unwrap(),
+ "A\n\r\t\\\0♥&#x27;&quot;&quot;\nA\n\r\t\\\0♥&#x27;&quot;&#x27;"
+ );
+}
+
struct Holder {
a: usize,
}