blob: 50d633e69dddc0ad93744f8b5aa075e1084e8fc1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
extern crate handlebars;
use std::fs::File;
use std::collections::BTreeMap;
use handlebars::Handlebars;
extern crate svgbob;
extern crate svg;
use handlebars::Context;
fn main() {
let svg_file = "screenshots/comic.svg";
let html_file = "comic.html";
let bob_str = include_str!("comic.bob");
let svg = svgbob::to_svg(bob_str);
svg::save(svg_file, &svg).unwrap();
println!("Saved to {}",svg_file);
let handlebars = Handlebars::new();
let mut m: BTreeMap<String, String> = BTreeMap::new();
m.insert("bob".to_string(),bob_str.to_owned());
m.insert("svg_file".to_string(), svg_file.to_string());
let context = Context::wraps(&m);
let mut source_template = File::open(&"web/index.hbs").unwrap();
let mut output_file = File::create(html_file).unwrap();
if let Ok(_) = handlebars.template_renderw2(&mut source_template, &context, &mut output_file) {
println!("Rendered to {}", html_file);
} else {
println!("Error");
};
}
|