aboutsummaryrefslogtreecommitdiffstats
path: root/testing/tests/include.rs
diff options
context:
space:
mode:
authorLibravatar max <gmx.sht@gmail.com>2023-12-11 16:43:16 +0200
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2024-01-17 17:58:53 +0100
commit5cad82f38e800a42717284f20e7e0923add1e32f (patch)
treec58e7220a9e8500b65f3eb116ea12c43bd92a61a /testing/tests/include.rs
parent514ae1b24cebb50cad04d0717092a9f890b7a245 (diff)
downloadaskama-5cad82f38e800a42717284f20e7e0923add1e32f.tar.gz
askama-5cad82f38e800a42717284f20e7e0923add1e32f.tar.bz2
askama-5cad82f38e800a42717284f20e7e0923add1e32f.zip
Allow included templates to `extend`, `import`, and `macro`
Signed-off-by: max <gmx.sht@gmail.com>
Diffstat (limited to '')
-rw-r--r--testing/tests/include.rs41
1 files changed, 41 insertions, 0 deletions
diff --git a/testing/tests/include.rs b/testing/tests/include.rs
index f461a7b..c11d96f 100644
--- a/testing/tests/include.rs
+++ b/testing/tests/include.rs
@@ -12,3 +12,44 @@ fn test_include() {
let s = IncludeTemplate { strs: &strs };
assert_eq!(s.render().unwrap(), "\n INCLUDED: foo\n INCLUDED: bar")
}
+
+#[derive(Template)]
+#[template(path = "include-extends.html")]
+struct IncludeExtendsTemplate<'a> {
+ name: &'a str,
+}
+
+#[test]
+fn test_include_extends() {
+ let template = IncludeExtendsTemplate { name: "Alice" };
+
+ assert_eq!(
+ template.render().unwrap(),
+ "<div>\n \
+ <h1>Welcome</h1>\n \
+ <div>\n \
+ <p>Below me is the header</p>\n \
+ foo\n \
+ <p>Above me is the header</p>\n\
+ </div>\n\
+ Hello, Alice!\n\
+ </div>"
+ );
+}
+
+#[derive(Template)]
+#[template(path = "include-macro.html")]
+struct IncludeMacroTemplate<'a> {
+ name: &'a str,
+ name2: &'a str,
+}
+
+#[test]
+fn test_include_macro() {
+ let template = IncludeMacroTemplate {
+ name: "Alice",
+ name2: "Bob",
+ };
+
+ assert_eq!(template.render().unwrap(), "Hello, Alice!\nHowdy, Bob!");
+}