Skip to content

Commit

Permalink
Add test for unescaped variable expressions (see #132)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheWaWaR authored and djc committed Oct 20, 2018
1 parent 4fa029f commit 5be6479
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
5 changes: 5 additions & 0 deletions testing/templates/simple-no-escape.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{# our very first test! #}
hello world, {{ strvar }}
with number: {{ num }}
Iñtërnâtiônàlizætiøn is important
in vars too: {{ i18n }}
24 changes: 24 additions & 0 deletions testing/tests/simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,30 @@ fn test_variables() {
assert_eq!(VariablesTemplate::extension(), Some("html"));
}

#[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 {
Expand Down

0 comments on commit 5be6479

Please sign in to comment.