diff options
author | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2017-02-05 15:18:47 +0100 |
---|---|---|
committer | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2017-02-05 15:18:47 +0100 |
commit | 723567ba0c8d28a292b87d6d65cb97e4b4406e4b (patch) | |
tree | 0e27ef09553e55acff4789260928080e9c911c23 /testing | |
parent | 2355f4eb0b8fb33ef2d0994f4f54aa2615b8fa29 (diff) | |
download | askama-723567ba0c8d28a292b87d6d65cb97e4b4406e4b.tar.gz askama-723567ba0c8d28a292b87d6d65cb97e4b4406e4b.tar.bz2 askama-723567ba0c8d28a292b87d6d65cb97e4b4406e4b.zip |
Implement basic support for template inheritance
Diffstat (limited to 'testing')
-rw-r--r-- | testing/templates/base.html | 2 | ||||
-rw-r--r-- | testing/templates/child.html | 2 | ||||
-rw-r--r-- | testing/tests/inheritance.rs | 19 |
3 files changed, 23 insertions, 0 deletions
diff --git a/testing/templates/base.html b/testing/templates/base.html new file mode 100644 index 0000000..f40d867 --- /dev/null +++ b/testing/templates/base.html @@ -0,0 +1,2 @@ +{% block content %}{% endblock %} +Copyright 2017 diff --git a/testing/templates/child.html b/testing/templates/child.html new file mode 100644 index 0000000..23aed37 --- /dev/null +++ b/testing/templates/child.html @@ -0,0 +1,2 @@ +{% extends "base.html" %} +{% block content %}Content goes here{% endblock %} diff --git a/testing/tests/inheritance.rs b/testing/tests/inheritance.rs new file mode 100644 index 0000000..ebcca70 --- /dev/null +++ b/testing/tests/inheritance.rs @@ -0,0 +1,19 @@ +extern crate askama; +#[macro_use] +extern crate askama_derive; + +use askama::Template; + +#[derive(Template)] +#[template(path = "base.html")] +struct BaseTemplate { } + +#[derive(Template)] +#[template(path = "child.html")] +struct ChildTemplate { } + +#[test] +fn test_simple_extends() { + let t = ChildTemplate { }; + assert_eq!(t.render(), "Content goes here\nCopyright 2017\n"); +} |