| 1 | extern crate handlebars; |
| 2 | #[macro_use] |
| 3 | extern crate serde_json; |
| 4 | |
| 5 | use handlebars::Handlebars; |
| 6 | |
| 7 | #[test] |
| 8 | fn test_root_var() { |
| 9 | let hbs = Handlebars::new(); |
| 10 | |
| 11 | let data = json!({ |
| 12 | "a": [1, 2, 3, 4], |
| 13 | "b": "top" |
| 14 | }); |
| 15 | |
| 16 | assert_eq!( |
| 17 | hbs.render_template("{{#each a}}{{@root/b}}: {{this}};{{/each}}", &data) |
| 18 | .unwrap(), |
| 19 | "top: 1;top: 2;top: 3;top: 4;" |
| 20 | ); |
| 21 | } |