aboutsummaryrefslogtreecommitdiffstats
path: root/testing/tests/inheritance.rs
blob: 156358e224a4e097cbf164850ec7f3918c420873 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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 {
    _parent: BaseTemplate,
}

#[test]
fn test_use_base_directly() {
    let t = BaseTemplate {};
    assert_eq!(t.render(), "\nCopyright 2017\n");
}

#[test]
fn test_simple_extends() {
    let t = ChildTemplate { _parent: BaseTemplate {} };
    assert_eq!(t.render(), "Content goes here\nCopyright 2017\n");
}