diff options
author | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2017-09-05 20:34:32 +0200 |
---|---|---|
committer | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2017-09-05 20:34:32 +0200 |
commit | 7203fac07cabe68047033a75ddb2db417a9ef6c6 (patch) | |
tree | 379415fdd1ff7547859099533ee7ac3d6e855426 /testing/tests/simple.rs | |
parent | f02ade3b94e0eb7f97498439142a2448ebdcdfcc (diff) | |
download | askama-7203fac07cabe68047033a75ddb2db417a9ef6c6.tar.gz askama-7203fac07cabe68047033a75ddb2db417a9ef6c6.tar.bz2 askama-7203fac07cabe68047033a75ddb2db417a9ef6c6.zip |
Add some tests for escaping functionality
Diffstat (limited to '')
-rw-r--r-- | testing/tests/simple.rs | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/testing/tests/simple.rs b/testing/tests/simple.rs index 93faf50..57887c8 100644 --- a/testing/tests/simple.rs +++ b/testing/tests/simple.rs @@ -181,3 +181,42 @@ fn test_composition() { let t = CompositionTemplate { foo: IfTemplate { cond: true } }; assert_eq!(t.render().unwrap(), "composed: true"); } + + +#[derive(Template)] +#[template(source = "{{ foo }}")] +struct ImplicitEscapedTemplate<'a> { + foo: &'a str, +} + +#[test] +fn test_implicit_escaped() { + let t = ImplicitEscapedTemplate { foo: "foo & bar" }; + assert_eq!(t.render().unwrap(), "foo & bar"); +} + + +#[derive(Template)] +#[template(source = "{{ foo }}", escape = "html")] +struct ExplicitEscapedTemplate<'a> { + foo: &'a str, +} + +#[test] +fn test_explicit_escaped() { + let t = ExplicitEscapedTemplate { foo: "foo & bar" }; + assert_eq!(t.render().unwrap(), "foo & bar"); +} + + +#[derive(Template)] +#[template(source = "{{ foo }}", escape = "none")] +struct UnescapedTemplate<'a> { + foo: &'a str, +} + +#[test] +fn test_unescaped() { + let t = UnescapedTemplate { foo: "foo & bar" }; + assert_eq!(t.render().unwrap(), "foo & bar"); +} |