From e29792e90ce438875a13becdeb9c030b1d3132e4 Mon Sep 17 00:00:00 2001 From: Pavel Fokin Date: Thu, 11 Apr 2019 07:48:38 +0300 Subject: WIP: Add raw block --- testing/templates/raw-complex.html | 5 +++++ testing/templates/raw-simple.html | 3 +++ testing/tests/simple.rs | 23 +++++++++++++++++++++++ 3 files changed, 31 insertions(+) create mode 100644 testing/templates/raw-complex.html create mode 100644 testing/templates/raw-simple.html (limited to 'testing') diff --git a/testing/templates/raw-complex.html b/testing/templates/raw-complex.html new file mode 100644 index 0000000..c3e5a7a --- /dev/null +++ b/testing/templates/raw-complex.html @@ -0,0 +1,5 @@ +{% raw %} +{% block name %} + {{ name }} +{% endblock %} +{% endraw %} diff --git a/testing/templates/raw-simple.html b/testing/templates/raw-simple.html new file mode 100644 index 0000000..125a0b5 --- /dev/null +++ b/testing/templates/raw-simple.html @@ -0,0 +1,3 @@ +{% raw %} +{{ name }} +{% endraw %} diff --git a/testing/tests/simple.rs b/testing/tests/simple.rs index f192609..e4239ce 100644 --- a/testing/tests/simple.rs +++ b/testing/tests/simple.rs @@ -300,6 +300,29 @@ fn test_empty() { assert_eq!(Empty.render().unwrap(), "foo"); } +#[derive(Template)] +#[template(path = "raw-simple.html")] +struct RawTemplate; + +#[test] +fn test_raw_simple() { + let template = RawTemplate; + assert_eq!(template.render().unwrap(), "\n{{ name }}\n"); +} + +#[derive(Template)] +#[template(path = "raw-complex.html")] +struct RawTemplateComplex; + +#[test] +fn test_raw_complex() { + let template = RawTemplateComplex; + assert_eq!( + template.render().unwrap(), + "\n{% block name %}\n {{ name }}\n{% endblock %}\n" + ); +} + mod without_import_on_derive { #[derive(askama::Template)] #[template(source = "foo", ext = "txt")] -- cgit