From 12e178ce405225f2cd65ab4f68b67fefc89dec2b Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 10 Jan 2024 15:10:06 +0100 Subject: Add test for `as_ref` builtin filter --- testing/tests/filters.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'testing/tests') 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#""# ); } + +#[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") +} -- cgit