aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2017-08-04 13:19:31 +0200
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2017-08-04 13:21:55 +0200
commit549d0ec3c6799eb31517b093faa7c85752ba7d8c (patch)
treebe947ea5fbba0c9d6718a4a85cc5d12d1ff002d2
parent51eee57b84adf7fe72b7aa9b23e3ef974baad5a4 (diff)
downloadaskama-549d0ec3c6799eb31517b093faa7c85752ba7d8c.tar.gz
askama-549d0ec3c6799eb31517b093faa7c85752ba7d8c.tar.bz2
askama-549d0ec3c6799eb31517b093faa7c85752ba7d8c.zip
Add test for include blocks (see #25)
Diffstat (limited to '')
-rw-r--r--testing/templates/include.html3
-rw-r--r--testing/templates/included.html1
-rw-r--r--testing/tests/include.rs19
3 files changed, 23 insertions, 0 deletions
diff --git a/testing/templates/include.html b/testing/templates/include.html
new file mode 100644
index 0000000..cdafbad
--- /dev/null
+++ b/testing/templates/include.html
@@ -0,0 +1,3 @@
+{% for s in strs -%}
+ {% include "included.html" %}
+{%- endfor %}
diff --git a/testing/templates/included.html b/testing/templates/included.html
new file mode 100644
index 0000000..ff10488
--- /dev/null
+++ b/testing/templates/included.html
@@ -0,0 +1 @@
+INCLUDED: {{ s }}
diff --git a/testing/tests/include.rs b/testing/tests/include.rs
new file mode 100644
index 0000000..7ddccd2
--- /dev/null
+++ b/testing/tests/include.rs
@@ -0,0 +1,19 @@
+#[macro_use]
+extern crate askama;
+
+use askama::Template;
+
+#[derive(Template)]
+#[template(path = "include.html")]
+struct IncludeTemplate<'a> {
+ strs: &'a [&'a str],
+}
+
+#[test]
+fn test_include() {
+ let strs = vec!["foo", "bar"];
+ let s = IncludeTemplate {
+ strs: &strs,
+ };
+ assert_eq!(s.render(), "INCLUDED: fooINCLUDED: bar")
+}