Debian Codegraph @

examples/script.rs

raw symbols SCIP
1 #![allow(unused_imports)]
2
3 use handlebars::Handlebars;
4 use std::error::Error;
5 #[macro_use]
6 extern crate serde_json;
7
8 fn main() -> Result<(), Box<dyn Error>> {
9 let mut handlebars = Handlebars::new();
10
11 handlebars.register_template_file("tpl", "./examples/script/template.hbs")?;
12 handlebars.register_script_helper_file("score", "./examples/script/goals.rhai")?;
13
14 let data = json! {[
15 [{
16 "name": "Dortmund",
17 "goals": ["Haaland", "Guerreiro", "Hazard", "Guerreiro"]
18 }, {
19 "name": "Schalke",
20 "goals": []
21 }],
22 [{
23 "name": "RB Leipzig",
24 "goals": ["Poulsen"]
25 }, {
26 "name": "SC Feriburg",
27 "goals": ["Gulde"]
28 }]
29 ]};
30 println!("{}", handlebars.render("tpl", &data)?);
31 Ok(())
32 }