aboutsummaryrefslogtreecommitdiff
path: root/src/generator/html.rs
diff options
context:
space:
mode:
authorRuben Beltran del Rio <git@r.bdr.sh>2025-01-05 15:48:16 +0100
committerRuben Beltran del Rio <git@r.bdr.sh>2025-01-05 15:48:16 +0100
commitb17907faf8d9693cef94a6048d802bd4ced9102f (patch)
tree1bd87c40e85af675a96b63672163b4caaa174364 /src/generator/html.rs
parentd7fef30ac3f539975ef9edbba8e0af4a4e9ff3de (diff)
Deal with all lints
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(())
}