From b076422562e856cbc78ec3d37f7e505214294890 Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Mon, 25 Dec 2017 12:30:27 +0100 Subject: Add test case for cross-module inheritance --- testing/tests/inheritance.rs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/testing/tests/inheritance.rs b/testing/tests/inheritance.rs index bac9bf5..a36f634 100644 --- a/testing/tests/inheritance.rs +++ b/testing/tests/inheritance.rs @@ -29,3 +29,32 @@ fn test_simple_extends() { "Bar\n(Bar) Content goes here\nFoo\nCopyright 2017" ); } + + +pub mod parent { + use askama::Template; + #[derive(Template)] + #[template(path = "base.html")] + pub struct BaseTemplate<'a> { + pub title: &'a str, + } +} + +pub mod child { + use askama::Template; + use super::parent::*; + #[derive(Template)] + #[template(path = "child.html")] + pub struct ChildTemplate<'a> { + pub _parent: BaseTemplate<'a>, + } +} + +#[test] +fn test_different_module() { + let t = child::ChildTemplate { _parent: parent::BaseTemplate { title: "a" } }; + assert_eq!( + t.render().unwrap(), + "a\n(a) Content goes here\nFoo\nCopyright 2017" + ); +} -- cgit