aboutsummaryrefslogtreecommitdiffstats
path: root/testing
diff options
context:
space:
mode:
authorLibravatar defyrlt <defyrlt@users.noreply.github.com>2017-08-29 23:02:13 +0300
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2017-09-02 13:34:52 +0200
commit7d2d7718aa8467ddd5ca9753bde2c7a87ff55c9f (patch)
tree98618ab42faa8e64d9ad96f19379e3ec82041a3e /testing
parentb0ea82d87aa61576d1565f20276d411295b9a19d (diff)
downloadaskama-7d2d7718aa8467ddd5ca9753bde2c7a87ff55c9f.tar.gz
askama-7d2d7718aa8467ddd5ca9753bde2c7a87ff55c9f.tar.bz2
askama-7d2d7718aa8467ddd5ca9753bde2c7a87ff55c9f.zip
Add `join` filter & tests for it
Diffstat (limited to '')
-rw-r--r--testing/templates/filters_join.html1
-rw-r--r--testing/tests/filters.rs25
2 files changed, 26 insertions, 0 deletions
diff --git a/testing/templates/filters_join.html b/testing/templates/filters_join.html
new file mode 100644
index 0000000..61cc249
--- /dev/null
+++ b/testing/templates/filters_join.html
@@ -0,0 +1 @@
+{{ s|join(", ") }}
diff --git a/testing/tests/filters.rs b/testing/tests/filters.rs
index 524014e..b24ff61 100644
--- a/testing/tests/filters.rs
+++ b/testing/tests/filters.rs
@@ -49,3 +49,28 @@ fn test_my_filter() {
let t = MyFilterTemplate { s: "foo" };
assert_eq!(t.render().unwrap(), "faa");
}
+
+
+#[derive(Template)]
+#[template(path= "filters_join.html")]
+struct JoinTemplate<'a> {
+ s: &'a [&'a str],
+}
+
+#[test]
+fn test_join() {
+ let t = JoinTemplate { s: &["foo", "bar", "bazz"] };
+ assert_eq!(t.render().unwrap(), "foo, bar, bazz");
+}
+
+#[derive(Template)]
+#[template(path= "filters_join.html")]
+struct VecJoinTemplate {
+ s: Vec<String>
+}
+
+#[test]
+fn test_vec_join() {
+ let t = VecJoinTemplate { s: vec!["foo".into(), "bar".into(), "bazz".into()] };
+ assert_eq!(t.render().unwrap(), "foo, bar, bazz");
+}