From 3b7078034092774ef46b61c37266cd2918314897 Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Sun, 12 Feb 2017 20:42:43 +0100 Subject: Test support for variables in inherited templates --- testing/tests/inheritance.rs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'testing/tests') diff --git a/testing/tests/inheritance.rs b/testing/tests/inheritance.rs index 156358e..2fd06ba 100644 --- a/testing/tests/inheritance.rs +++ b/testing/tests/inheritance.rs @@ -6,22 +6,24 @@ use askama::Template; #[derive(Template)] #[template(path = "base.html")] -struct BaseTemplate { } +struct BaseTemplate<'a> { + title: &'a str, +} #[derive(Template)] #[template(path = "child.html")] -struct ChildTemplate { - _parent: BaseTemplate, +struct ChildTemplate<'a> { + _parent: BaseTemplate<'a>, } #[test] fn test_use_base_directly() { - let t = BaseTemplate {}; - assert_eq!(t.render(), "\nCopyright 2017\n"); + let t = BaseTemplate { title: "Foo" }; + assert_eq!(t.render(), "Foo\n\nCopyright 2017\n"); } #[test] fn test_simple_extends() { - let t = ChildTemplate { _parent: BaseTemplate {} }; - assert_eq!(t.render(), "Content goes here\nCopyright 2017\n"); + let t = ChildTemplate { _parent: BaseTemplate { title: "Bar" } }; + assert_eq!(t.render(), "Bar\nContent goes here\nCopyright 2017\n"); } -- cgit