use handlebars::Handlebars;
use std::collections::HashMap;
use web_sys::window;
#[derive(Default)]
pub struct App {
handlebars: Handlebars<'static>,
}
impl App {
pub fn new() -> Self {
Self::default()
}
pub fn handlebars(&mut self) -> &mut Handlebars<'static> {
&mut self.handlebars
}
pub fn start(&self) -> anyhow::Result<()> {
console_error_panic_hook::set_once();
let document = window()
.and_then(|win| win.document())
.expect("Could not access document");
let body = document.body().expect("Could not access document body");
let data: HashMap<String, String> = HashMap::new();
let html = self
.handlebars
.render("application", &data)
.expect("Could not render application.hbs");
body.set_inner_html(&html);
Ok(())
}
}