| 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}}") |
| 17 | .unwrap(); |
| 18 | assert_eq!(hbs.render_template("{{> foo/bar }}", &data).unwrap(), "top"); |
| 19 | } |
| 20 | |
| 21 | #[test] |
| 22 | fn test_walk_dir_template_name_with_args() { |
| 23 | let mut hbs = Handlebars::new(); |
| 24 | |
| 25 | let data = json!({ |
| 26 | "a": [1, 2, 3, 4], |
| 27 | "b": "top" |
| 28 | }); |
| 29 | |
| 30 | hbs.register_template_string("foo/bar", "{{this}}").unwrap(); |
| 31 | assert_eq!( |
| 32 | hbs.render_template("{{> foo/bar b }}", &data).unwrap(), |
| 33 | "top" |
| 34 | ); |
| 35 | } |