aboutsummaryrefslogtreecommitdiff
path: root/src/generator/html.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/generator/html.rs')
-rw-r--r--src/generator/html.rs27
1 files changed, 12 insertions, 15 deletions
diff --git a/src/generator/html.rs b/src/generator/html.rs
index 7b36944..70cc320 100644
--- a/src/generator/html.rs
+++ b/src/generator/html.rs
@@ -1,25 +1,22 @@
-use crate::template::{find, parse, TemplateContext};
+use crate::template::{find, parse, Context};
use std::fs::write;
use std::io::{Error, ErrorKind::Other, Result};
-use std::path::PathBuf;
+use std::path::Path;
const FILENAME: &str = "index.html";
pub fn generate(
- _: &PathBuf,
- template_directory: &PathBuf,
- target: &PathBuf,
- context: &TemplateContext,
+ _: &Path,
+ template_directory: &Path,
+ target: &Path,
+ context: &Context,
) -> Result<()> {
- match find(template_directory, FILENAME) {
- Some(template) => {
- 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)?;
- }
- None => {}
+ 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(())
}