aboutsummaryrefslogtreecommitdiffstats
path: root/testing
diff options
context:
space:
mode:
authorLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2017-02-12 20:42:43 +0100
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2017-02-12 20:42:43 +0100
commit3b7078034092774ef46b61c37266cd2918314897 (patch)
treefb4c49b6bd611ccab3932a2144270a8e031bb876 /testing
parentc74e9e8971c06ed77eeee79cbac2c4c325b3ffa4 (diff)
downloadaskama-3b7078034092774ef46b61c37266cd2918314897.tar.gz
askama-3b7078034092774ef46b61c37266cd2918314897.tar.bz2
askama-3b7078034092774ef46b61c37266cd2918314897.zip
Test support for variables in inherited templates
Diffstat (limited to 'testing')
-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");
}