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