aboutsummaryrefslogtreecommitdiffstats
path: root/testing/tests/inheritance.rs
diff options
context:
space:
mode:
authorLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2017-12-25 12:30:27 +0100
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2017-12-25 12:30:27 +0100
commitb076422562e856cbc78ec3d37f7e505214294890 (patch)
tree05cf058a960667226c80a09b68902480888bef65 /testing/tests/inheritance.rs
parent8afa4d9aec0a9c9321eff4e90db99ab576b7f2a9 (diff)
downloadaskama-b076422562e856cbc78ec3d37f7e505214294890.tar.gz
askama-b076422562e856cbc78ec3d37f7e505214294890.tar.bz2
askama-b076422562e856cbc78ec3d37f7e505214294890.zip
Add test case for cross-module inheritance
Diffstat (limited to 'testing/tests/inheritance.rs')
-rw-r--r--testing/tests/inheritance.rs29
1 files changed, 29 insertions, 0 deletions
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"
+ );
+}