]> git.proxmox.com Git - rustc.git/blob - vendor/handlebars/tests/template_names.rs
New upstream version 1.45.0+dfsg1
[rustc.git] / vendor / handlebars / tests / template_names.rs
1 extern crate handlebars;
2 #[macro_use]
3 extern crate serde_json;
4
5 use handlebars::Handlebars;
6
7 #[test]
8 fn test_walk_dir_template_name() {
9 let mut hbs = Handlebars::new();
10
11 let data = json!({
12 "a": [1, 2, 3, 4],
13 "b": "top"
14 });
15
16 hbs.register_template_string("foo/bar", "{{@root/b}}").unwrap();
17 assert_eq!(
18 hbs.render_template("{{> foo/bar }}", &data)
19 .unwrap(),
20 "top"
21 );
22 }
23
24 #[test]
25 fn test_walk_dir_template_name_with_args() {
26 let mut hbs = Handlebars::new();
27
28 let data = json!({
29 "a": [1, 2, 3, 4],
30 "b": "top"
31 });
32
33 hbs.register_template_string("foo/bar", "{{this}}").unwrap();
34 assert_eq!(
35 hbs.render_template("{{> foo/bar b }}", &data)
36 .unwrap(),
37 "top"
38 );
39 }