diff options
-rw-r--r-- | testing/tests/filters.rs | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/testing/tests/filters.rs b/testing/tests/filters.rs index 1f382f6..be3e0ab 100644 --- a/testing/tests/filters.rs +++ b/testing/tests/filters.rs @@ -27,6 +27,54 @@ fn filter_escape() { } #[derive(Template)] +#[template( + source = "{{ \"<h1 class=\\\"title\\\">Foo Bar</h1>\"|escape(\"none\") }} +{{ \"<h1 class=\\\"title\\\">Foo Bar</h1>\"|escape(\"html\") }} +{{ \"<h1 class=\\\"title\\\">Foo Bar</h1>\"|escape }} +{{ \"<h1 class=\\\"title\\\">Foo Bar</h1>\" }} +", + ext = "txt", + escape = "none" +)] +struct OptEscaperNoneTemplate; + +#[test] +fn filter_opt_escaper_none() { + let t = OptEscaperNoneTemplate; + assert_eq!( + t.render().unwrap(), + r#"<h1 class="title">Foo Bar</h1> +<h1 class="title">Foo Bar</h1> +<h1 class="title">Foo Bar</h1> +<h1 class="title">Foo Bar</h1>"# + ); +} + +#[derive(Template)] +#[template( + source = "{{ \"<h1 class=\\\"title\\\">Foo Bar</h1>\"|escape(\"none\") }} +{{ \"<h1 class=\\\"title\\\">Foo Bar</h1>\"|escape(\"html\") }} +{{ \"<h1 class=\\\"title\\\">Foo Bar</h1>\"|escape }} +{{ \"<h1 class=\\\"title\\\">Foo Bar</h1>\" }} +", + ext = "txt", + escape = "html" +)] +struct OptEscaperHtmlTemplate; + +#[test] +fn filter_opt_escaper_html() { + let t = OptEscaperHtmlTemplate; + assert_eq!( + t.render().unwrap(), + r#"<h1 class="title">Foo Bar</h1> +<h1 class="title">Foo Bar</h1> +<h1 class="title">Foo Bar</h1> +<h1 class="title">Foo Bar</h1>"# + ); +} + +#[derive(Template)] #[template(path = "format.html", escape = "none")] struct FormatTemplate<'a> { var: &'a str, |