]> git.r.bdr.sh - rbdr/blog/blob - src/generator/html.rs
b7ddd45770432f76a3f272da1dd6713e9e97e178
[rbdr/blog] / src / generator / html.rs
1 use std::fs::write;
2 use std::io::Result;
3 use std::path::PathBuf;
4 use crate::template::{find, parse, TemplateContext};
5
6 const FILENAME: &str = "index.html";
7
8 pub fn generate(_: &PathBuf, template_directory: &PathBuf, target: &PathBuf, context: &TemplateContext) -> Result<()> {
9 match find(template_directory, FILENAME) {
10 Some(template) => {
11 let parsed_template = parse(&template);
12 let rendered_template = parsed_template.render(context);
13 let location = target.join(FILENAME);
14 write(location, rendered_template)?;
15 },
16 None => {}
17 }
18 Ok(())
19 }