aboutsummaryrefslogtreecommitdiffstats
path: root/testing/tests/ext.rs
blob: 5ed4e724b625875ec247b3bfbbd69b4c4eda6de3 (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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
use askama::Template;

#[derive(Template)]
#[template(path = "foo.html")]
struct PathHtml;

#[test]
fn test_path_ext_html() {
    let t = PathHtml;
    assert_eq!(t.render().unwrap(), "foo.html");
    assert_eq!(t.extension(), Some("html"));
}

#[derive(Template)]
#[template(path = "foo.jinja")]
struct PathJinja;

#[test]
fn test_path_ext_jinja() {
    let t = PathJinja;
    assert_eq!(t.render().unwrap(), "foo.jinja");
    assert_eq!(t.extension(), Some("jinja"));
}

#[derive(Template)]
#[template(path = "foo.html.jinja")]
struct PathHtmlJinja;

#[test]
fn test_path_ext_html_jinja() {
    let t = PathHtmlJinja;
    assert_eq!(t.render().unwrap(), "foo.html.jinja");
    assert_eq!(t.extension(), Some("html"));
}

#[derive(Template)]
#[template(path = "foo.html", ext = "txt")]
struct PathHtmlAndExtTxt;

#[test]
fn test_path_ext_html_and_ext_txt() {
    let t = PathHtmlAndExtTxt;
    assert_eq!(t.render().unwrap(), "foo.html");
    assert_eq!(t.extension(), Some("txt"));
}

#[derive(Template)]
#[template(path = "foo.jinja", ext = "txt")]
struct PathJinjaAndExtTxt;

#[test]
fn test_path_ext_jinja_and_ext_txt() {
    let t = PathJinjaAndExtTxt;
    assert_eq!(t.render().unwrap(), "foo.jinja");
    assert_eq!(t.extension(), Some("txt"));
}

#[derive(Template)]
#[template(path = "foo.html.jinja", ext = "txt")]
struct PathHtmlJinjaAndExtTxt;

#[test]
fn test_path_ext_html_jinja_and_ext_txt() {
    let t = PathHtmlJinjaAndExtTxt;
    assert_eq!(t.render().unwrap(), "foo.html.jinja");
    assert_eq!(t.extension(), Some("txt"));
}