blob: 6b0eca5d0b0343d116f5cc863e6b10f556e08ade (
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
68
69
70
71
72
73
74
75
|
use askama::Template;
#[derive(Template)]
#[template(path = "macro.html")]
struct MacroTemplate<'a> {
s: &'a str,
}
#[test]
fn test_macro() {
let t = MacroTemplate { s: "foo" };
assert_eq!(t.render().unwrap(), "12foo foo foo34foo foo5");
}
#[derive(Template)]
#[template(path = "import.html")]
struct ImportTemplate<'a> {
s: &'a str,
}
#[test]
fn test_import() {
let t = ImportTemplate { s: "foo" };
assert_eq!(t.render().unwrap(), "foo foo foo");
}
#[derive(Template)]
#[template(path = "deep-nested-macro.html")]
struct NestedTemplate;
#[test]
fn test_nested() {
let t = NestedTemplate;
assert_eq!(t.render().unwrap(), "foo");
}
#[derive(Template)]
#[template(path = "deep-import-parent.html")]
struct DeepImportTemplate;
#[test]
fn test_deep_import() {
let t = DeepImportTemplate;
assert_eq!(t.render().unwrap(), "foo");
}
#[derive(Template)]
#[template(path = "macro-short-circuit.html")]
struct ShortCircuitTemplate {}
#[test]
fn test_short_circuit() {
let t = ShortCircuitTemplate {};
assert_eq!(t.render().unwrap(), "truetruetruefalsetruetrue");
}
#[derive(Template)]
#[template(path = "nested-macro-args.html")]
struct NestedMacroArgsTemplate {}
#[test]
fn test_nested_macro_with_args() {
let t = NestedMacroArgsTemplate {};
assert_eq!(t.render().unwrap(), "first second");
}
#[derive(Template)]
#[template(path = "macro-import-str-cmp.html")]
struct StrCmpTemplate;
#[test]
fn str_cmp() {
let t = StrCmpTemplate;
assert_eq!(t.render().unwrap(), "AfooBotherCneitherD");
}
|