aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--testing/templates/base.html1
-rw-r--r--testing/tests/inheritance.rs16
2 files changed, 10 insertions, 7 deletions
diff --git a/testing/templates/base.html b/testing/templates/base.html
index f40d867..a588223 100644
--- a/testing/templates/base.html
+++ b/testing/templates/base.html
@@ -1,2 +1,3 @@
+{{ title }}
{% block content %}{% endblock %}
Copyright 2017
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");
}