aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2018-04-19 14:32:19 +0200
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2018-04-19 14:32:19 +0200
commit76b99dfc7db5dea9467b90c0cbc7289e811edf9f (patch)
treef1e797dcc0562aaea137d1917c90929e39384e04
parent248e74b6843cf2052e349c6b41a8a1eb9f245997 (diff)
downloadaskama-76b99dfc7db5dea9467b90c0cbc7289e811edf9f.tar.gz
askama-76b99dfc7db5dea9467b90c0cbc7289e811edf9f.tar.bz2
askama-76b99dfc7db5dea9467b90c0cbc7289e811edf9f.zip
Add test for filter in let statement
-rw-r--r--testing/tests/filters.rs22
1 files changed, 22 insertions, 0 deletions
diff --git a/testing/tests/filters.rs b/testing/tests/filters.rs
index 5ddd8c5..fc8c99f 100644
--- a/testing/tests/filters.rs
+++ b/testing/tests/filters.rs
@@ -128,3 +128,25 @@ fn test_nested_filter_ref() {
let t = NestedFilterTemplate { x: " floo & bar".to_string() };
assert_eq!(t.render().unwrap(), "floo & bar");
}
+
+
+#[derive(Template)]
+#[template(source = "{% let p = baz.print(foo.as_ref()) %}{{ p|upper }}", ext = "html")]
+struct FilterLetFilterTemplate {
+ foo: String,
+ baz: Baz,
+}
+
+struct Baz {}
+
+impl Baz {
+ fn print(&self, s: &str) -> String {
+ s.trim().to_owned()
+ }
+}
+
+#[test]
+fn test_filter_let_filter() {
+ let t = FilterLetFilterTemplate { foo: " bar ".to_owned(), baz: Baz {} };
+ assert_eq!(t.render().unwrap(), "BAR");
+}