]>
git.proxmox.com Git - rustc.git/blob - src/vendor/handlebars/examples/partials.rs
1 #![allow(unused_imports, dead_code)]
2 extern crate env_logger
;
3 extern crate handlebars
;
4 #[cfg(all(feature = "rustc_ser_type", not(feature = "serde_type")))]
5 extern crate rustc_serialize
;
10 use handlebars
::Handlebars
;
12 #[cfg(all(feature = "rustc_ser_type", not(feature = "serde_type"), feature = "partial_legacy"))]
14 env_logger
::init().unwrap();
15 let mut handlebars
= Handlebars
::new();
17 handlebars
.register_template_file("template",
18 &Path
::new("./examples/partials_legacy/template2.hbs"))
21 handlebars
.register_template_file("base0", &Path
::new("./examples/partials_legacy/base0.hbs"))
24 handlebars
.register_template_file("base1", &Path
::new("./examples/partials_legacy/base1.hbs"))
28 let data0
= btreemap
! {
29 "title".to_string() => "example 0".to_string(),
30 "parent".to_string() => "base0".to_string()
32 let data1
= btreemap
! {
33 "title".to_string() => "example 1".to_string(),
34 "parent".to_string() => "base1".to_string()
39 handlebars
.render("template", &data0
).unwrap_or_else(|e
| format
!("{}", e
)));
40 println
!("=======================================================");
44 handlebars
.render("template", &data1
).unwrap_or_else(|e
| format
!("{}", e
)));
47 #[cfg(feature = "serde_type")]
50 #[cfg(all(not(feature = "partial_legacy"), feature = "rustc_ser_type", not(feature="serde_type")))]
52 env_logger
::init().unwrap();
53 let mut handlebars
= Handlebars
::new();
55 handlebars
.register_template_file("template", &Path
::new("./examples/partials/template2.hbs"))
59 handlebars
.register_template_file("base0", &Path
::new("./examples/partials/base0.hbs"))
62 handlebars
.register_template_file("base1", &Path
::new("./examples/partials/base1.hbs"))
66 let data0
= btreemap
! {
67 "title".to_string() => "example 0".to_string(),
68 "parent".to_string() => "base0".to_string()
70 let data1
= btreemap
! {
71 "title".to_string() => "example 1".to_string(),
72 "parent".to_string() => "base1".to_string()
77 handlebars
.render("template", &data0
).unwrap_or_else(|e
| format
!("{}", e
)));
78 println
!("=======================================================");
82 handlebars
.render("template", &data1
).unwrap_or_else(|e
| format
!("{}", e
)));