khguide/src/kh3.rs

26 lines
653 B
Rust
Raw Normal View History

use askama::Template;
use food::Recipes;
use crate::create_file;
mod food;
const RECIPES_PATH: &str = "./input/kh3/recipes.toml";
#[derive(Template)]
#[template(path = "pages/kh3/food-sim.html")]
struct RecipesTemplate {
pub recipes: Recipes,
}
pub fn init() {
tracing::info!("Loading recipes data from {}", RECIPES_PATH);
let recipes_str = std::fs::read_to_string(RECIPES_PATH).unwrap();
let recipes = toml::from_str::<Recipes>(&recipes_str).unwrap();
tracing::info!("Generating the KH3 recipes template");
let food_template = RecipesTemplate { recipes };
create_file("./out/kh3", "food-sim", food_template.render().unwrap()).unwrap();
}