aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--askama_derive/src/lib.rs2
-rw-r--r--testing/tests/inheritance.rs12
2 files changed, 13 insertions, 1 deletions
diff --git a/askama_derive/src/lib.rs b/askama_derive/src/lib.rs
index cf5ead9..2c02cb5 100644
--- a/askama_derive/src/lib.rs
+++ b/askama_derive/src/lib.rs
@@ -54,7 +54,7 @@ fn build_template(ast: &syn::DeriveInput) -> String {
}
let ctx = &contexts[&input.path];
- let heritage = if !ctx.blocks.is_empty() {
+ let heritage = if !ctx.blocks.is_empty() || ctx.extends.is_some() {
Some(Heritage::new(ctx, &contexts))
} else {
None
diff --git a/testing/tests/inheritance.rs b/testing/tests/inheritance.rs
index 35fee80..32028c4 100644
--- a/testing/tests/inheritance.rs
+++ b/testing/tests/inheritance.rs
@@ -29,6 +29,18 @@ fn test_simple_extends() {
);
}
+#[derive(Template)]
+#[template(source = "{% extends \"base.html\" %}", ext = "html")]
+struct EmptyChild<'a> {
+ title: &'a str,
+}
+
+#[test]
+fn test_empty_child() {
+ let t = EmptyChild { title: "baz" };
+ assert_eq!(t.render().unwrap(), "baz\n\nFoo\nCopyright 2017");
+}
+
pub mod parent {
use askama::Template;
#[derive(Template)]