nom-nom-nix-gc/src/templates/mod.rs

25 lines
836 B
Rust

use handlebars::RenderError;
use serde_json::json;
use handlebars::Handlebars;
use std::{path::PathBuf, sync::Arc};
pub fn new<'a>() -> Result<Handlebars<'a>, RenderError> {
let rootpath = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
let landing_path = rootpath.join("src/templates/landing.hbs");
let mut hbs = handlebars::Handlebars::new();
let css = rootpath.join("src/templates/main.css");
let js = rootpath.join("src/templates/webauthn.js");
hbs.register_template_file("landing", landing_path.to_str().unwrap())?;
hbs.register_template_file("css", css.to_str().unwrap())?;
hbs.register_template_file("js", js.to_str().unwrap())?;
return Ok(hbs)
}
pub fn landing_page<'a>(hb: Arc<Handlebars<'a>>) -> Result<String, RenderError> {
let data = json!({
});
hb.render("landing", &data)
}