use crate::template::{find, parse, Context}; use std::fs::write; use std::io::{Error, ErrorKind::Other, Result}; use std::path::Path; const FILENAME: &str = "index.html"; pub fn generate( _: &Path, template_directory: &Path, target: &Path, context: &Context, ) -> Result<()> { if let Some(template) = find(template_directory, FILENAME) { let parsed_template = parse(&template).ok_or_else(|| Error::new(Other, "Unable to parse HTML template"))?; let rendered_template = parsed_template.render(context)?; let location = target.join(FILENAME); write(location, rendered_template)?; } Ok(()) }