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
extern crate tela;
use ;
/// Run `cargo run --example templates --features=tera,handlebars`
/// The templating engines are initialized with the server and create a slightly longer
/// startup and initial build time.
///
/// The `context!` macro is a way of constructing BTreeMaps. These are used for the variables being
/// exposed to the templating engines. The macro allows for "spreading" a BTreeMap, which in
/// reality just appends all the other values to the spread BTreeMap.
///
/// The `template!` macro allows for easy template construction. The macro expands to use the
/// context macro around whatever is inside of the curly brackets. It will also take the path to
/// the template relative to the root template path provided in the server builder method.
///
/// The server builder methods `tera` and `handlebars` serve to initialize the templating engines
/// along with providing the root template path, along with global variables. The first argument is
/// the path to the templates while the second is any BTreeMap<String, serde_json::Value> of global
/// values. The `context!` macro works great for creating this map.
async