diff options
author | Qian Linfeng <thewawar@gmail.com> | 2018-10-20 13:46:48 +0800 |
---|---|---|
committer | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2018-10-20 20:34:47 +0200 |
commit | 5be6479f2c4fc68b9a62f9359dda673be76ada15 (patch) | |
tree | b903e3f02053e30a84a8e062a8497b0ea82f534b /testing/tests/simple.rs | |
parent | 4fa029f26fd78b648024be1a2de6a143936c470d (diff) | |
download | askama-5be6479f2c4fc68b9a62f9359dda673be76ada15.tar.gz askama-5be6479f2c4fc68b9a62f9359dda673be76ada15.tar.bz2 askama-5be6479f2c4fc68b9a62f9359dda673be76ada15.zip |
Add test for unescaped variable expressions (see #132)
Diffstat (limited to 'testing/tests/simple.rs')
-rw-r--r-- | testing/tests/simple.rs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/testing/tests/simple.rs b/testing/tests/simple.rs index e19b32e..d4d2964 100644 --- a/testing/tests/simple.rs +++ b/testing/tests/simple.rs @@ -31,6 +31,30 @@ fn test_variables() { } #[derive(Template)] +#[template(path = "simple-no-escape.txt")] +struct VariablesTemplateNoEscape<'a> { + strvar: &'a str, + num: i64, + i18n: String, +} + +#[test] +fn test_variables_no_escape() { + let s = VariablesTemplateNoEscape { + strvar: "foo", + num: 42, + i18n: "Iñtërnâtiônàlizætiøn".to_string(), + }; + assert_eq!( + s.render().unwrap(), + "\nhello world, foo\n\ + with number: 42\n\ + Iñtërnâtiônàlizætiøn is important\n\ + in vars too: Iñtërnâtiônàlizætiøn" + ); +} + +#[derive(Template)] #[template(path = "if.html")] struct IfTemplate { cond: bool, |