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

25 lines
836 B
Rust
Raw Normal View History

2023-01-08 17:59:58 +01:00
use handlebars::RenderError;
use serde_json::json;
use handlebars::Handlebars;
2023-07-31 08:51:35 +02:00
use std::{path::PathBuf, sync::Arc};
pub fn new<'a>() -> Result<Handlebars<'a>, RenderError> {
2023-01-08 19:02:19 +01:00
let rootpath = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
let landing_path = rootpath.join("src/templates/landing.hbs");
let mut hbs = handlebars::Handlebars::new();
2023-01-08 19:02:19 +01:00
let css = rootpath.join("src/templates/main.css");
2023-01-22 18:12:45 +01:00
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())?;
2023-01-22 18:12:45 +01:00
hbs.register_template_file("js", js.to_str().unwrap())?;
return Ok(hbs)
}
2023-07-31 08:51:35 +02:00
pub fn landing_page<'a>(hb: Arc<Handlebars<'a>>) -> Result<String, RenderError> {
2023-01-08 17:59:58 +01:00
let data = json!({
});
hb.render("landing", &data)
}