1use handlebars::Handlebars;
2use std::collections::HashMap;
3use web_sys::window;
4
5#[derive(Default)]
6pub struct App {
7 handlebars: Handlebars<'static>,
8}
9
10impl App {
11 pub fn new() -> Self {
12 Self::default()
13 }
14
15 pub fn handlebars(&mut self) -> &mut Handlebars<'static> {
16 &mut self.handlebars
17 }
18
19 pub fn start(&self) -> anyhow::Result<()> {
20 console_error_panic_hook::set_once();
21
22 let document = window()
23 .and_then(|win| win.document())
24 .expect("Could not access document");
25 let body = document.body().expect("Could not access document body");
26
27 let data: HashMap<String, String> = HashMap::new();
28 let html = self
29 .handlebars
30 .render("application", &data)
31 .expect("Could not render application.hbs");
32 body.set_inner_html(&html);
33 Ok(())
34 }
35}