From c74e9e8971c06ed77eeee79cbac2c4c325b3ffa4 Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Sun, 12 Feb 2017 20:38:14 +0100 Subject: Explicitly pass trait implementation to top-level base template method This requires a base template struct to be a member of the derived template's context, but allows the base template to access base template fields. --- testing/tests/inheritance.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'testing') diff --git a/testing/tests/inheritance.rs b/testing/tests/inheritance.rs index 5d5c23c..156358e 100644 --- a/testing/tests/inheritance.rs +++ b/testing/tests/inheritance.rs @@ -10,7 +10,9 @@ struct BaseTemplate { } #[derive(Template)] #[template(path = "child.html")] -struct ChildTemplate { } +struct ChildTemplate { + _parent: BaseTemplate, +} #[test] fn test_use_base_directly() { @@ -20,6 +22,6 @@ fn test_use_base_directly() { #[test] fn test_simple_extends() { - let t = ChildTemplate { }; + let t = ChildTemplate { _parent: BaseTemplate {} }; assert_eq!(t.render(), "Content goes here\nCopyright 2017\n"); } -- cgit