File: root_var.rs

package info (click to toggle)
rust-handlebars 5.1.2-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 812 kB
  • sloc: sh: 3; makefile: 2
file content (21 lines) | stat: -rw-r--r-- 402 bytes parent folder | download | duplicates (35)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
extern crate handlebars;
#[macro_use]
extern crate serde_json;

use handlebars::Handlebars;

#[test]
fn test_root_var() {
    let hbs = Handlebars::new();

    let data = json!({
        "a": [1, 2, 3, 4],
        "b": "top"
    });

    assert_eq!(
        hbs.render_template("{{#each a}}{{@root/b}}: {{this}};{{/each}}", &data)
            .unwrap(),
        "top: 1;top: 2;top: 3;top: 4;"
    );
}