aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Guillaume Gomez <guillaume1.gomez@gmail.com>2024-01-10 15:10:06 +0100
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2024-01-12 10:38:15 +0100
commit12e178ce405225f2cd65ab4f68b67fefc89dec2b (patch)
treeb2916e25659ff6ef51839306fa8bd0f1a8d572d1
parentd5fbebecbd746e4dda0bcd81cb861b61afd8a309 (diff)
downloadaskama-12e178ce405225f2cd65ab4f68b67fefc89dec2b.tar.gz
askama-12e178ce405225f2cd65ab4f68b67fefc89dec2b.tar.bz2
askama-12e178ce405225f2cd65ab4f68b67fefc89dec2b.zip
Add test for `as_ref` builtin filter
-rw-r--r--testing/tests/filters.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/testing/tests/filters.rs b/testing/tests/filters.rs
index 5a02909..4fe5c62 100644
--- a/testing/tests/filters.rs
+++ b/testing/tests/filters.rs
@@ -309,3 +309,17 @@ fn test_json_script() {
r#"<script>var user = "\u003c/script\u003e\u003cbutton\u003eHacked!\u003c/button\u003e"</script>"#
);
}
+
+#[derive(askama::Template)]
+#[template(source = "{% let word = s|as_ref %}{{ word }}", ext = "html")]
+struct LetBorrow {
+ s: String,
+}
+
+#[test]
+fn test_let_borrow() {
+ let template = LetBorrow {
+ s: "hello".to_owned(),
+ };
+ assert_eq!(template.render().unwrap(), "hello")
+}