aboutsummaryrefslogtreecommitdiffstats
path: root/testing/tests
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--testing/tests/loop_else.rs19
1 files changed, 19 insertions, 0 deletions
diff --git a/testing/tests/loop_else.rs b/testing/tests/loop_else.rs
new file mode 100644
index 0000000..99dfc4b
--- /dev/null
+++ b/testing/tests/loop_else.rs
@@ -0,0 +1,19 @@
+use askama::Template;
+
+#[derive(Template)]
+#[template(
+ source = "{% for v in values %}{{ v }}{% else %}empty{% endfor %}",
+ ext = "txt"
+)]
+struct ForElse<'a> {
+ values: &'a [i32],
+}
+
+#[test]
+fn test_for_else() {
+ let t = ForElse { values: &[1, 2, 3] };
+ assert_eq!(t.render().unwrap(), "123");
+
+ let t = ForElse { values: &[] };
+ assert_eq!(t.render().unwrap(), "empty");
+}