diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:02:58 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:02:58 +0000 |
commit | 698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch) | |
tree | 173a775858bd501c378080a10dca74132f05bc50 /vendor/handlebars/examples/partials.rs | |
parent | Initial commit. (diff) | |
download | rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip |
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/handlebars/examples/partials.rs')
-rw-r--r-- | vendor/handlebars/examples/partials.rs | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/vendor/handlebars/examples/partials.rs b/vendor/handlebars/examples/partials.rs new file mode 100644 index 000000000..80b20c2f7 --- /dev/null +++ b/vendor/handlebars/examples/partials.rs @@ -0,0 +1,35 @@ +extern crate env_logger; +extern crate handlebars; +#[macro_use] +extern crate maplit; + +use handlebars::Handlebars; +use std::error::Error; + +fn main() -> Result<(), Box<dyn Error>> { + env_logger::init(); + let mut handlebars = Handlebars::new(); + + handlebars.register_template_file("template", "./examples/partials/template2.hbs")?; + + handlebars.register_template_file("base0", "./examples/partials/base0.hbs")?; + handlebars.register_template_file("base1", "./examples/partials/base1.hbs")?; + + let data0 = btreemap! { + "title".to_string() => "example 0".to_string(), + "parent".to_string() => "base0".to_string() + }; + let data1 = btreemap! { + "title".to_string() => "example 1".to_string(), + "parent".to_string() => "base1".to_string() + }; + + println!("Page 0"); + println!("{}", handlebars.render("template", &data0)?); + println!("======================================================="); + + println!("Page 1"); + println!("{}", handlebars.render("template", &data1)?); + + Ok(()) +} |