index : livejrnl-rs.git

ascending towards madness

author berrysweet <berrysweet@noreply.codeberg.org> 2023-07-06 10:59:11.0 +00:00:00
committer berrysweet <berrysweet@noreply.codeberg.org> 2023-07-06 10:59:11.0 +00:00:00
commit
d91b6c0f6a8a0b81ee31026e7180a8dd00b9676a [patch]
tree
b0f1453388b722a21755f2e33a252f8381e541ef
parent
5c5d5c4eb104f7bb134a24d3ac35dbc1dbb86650
download
d91b6c0f6a8a0b81ee31026e7180a8dd00b9676a.tar.gz

style: add static typing



Diff

 src/util/templating.rs | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/util/templating.rs b/src/util/templating.rs
index 88bd4b1..6232061 100644
--- a/src/util/templating.rs
+++ b/src/util/templating.rs
@@ -1,4 +1,5 @@
use std::collections::HashMap;
use std::path::Path;
use std::path::PathBuf;
use std::str::FromStr;
use walkdir::WalkDir;
@@ -6,13 +7,13 @@ use minijinja::{Environment, context};
use crate::data::formats::RenderConfig;

pub fn get_templates(template: String) -> HashMap<String, String> {
	let template_path = PathBuf::from_str(&template);
	let template_path: PathBuf = PathBuf::from_str(&template).unwrap();
	let mut templates: HashMap<String, String> = HashMap::new();
	for path in WalkDir::new(template_path.unwrap()).into_iter().filter_map(|e| e.ok()) {
	for path in WalkDir::new(template_path).into_iter().filter_map(|e| e.ok()) {
		if path.metadata().unwrap().is_file() {
			let relative_path = PathBuf::from(path.path());
			let relative_path = relative_path.strip_prefix(&template).unwrap();
			let full_path = path.path().display().to_string();
			let relative_path: PathBuf = PathBuf::from(path.path());
			let relative_path: &Path = relative_path.strip_prefix(&template).unwrap();
			let full_path: String = path.path().display().to_string();
			if let Ok(file) = std::fs::read_to_string(&full_path) {
				templates.insert(relative_path.to_str().unwrap_or_default().to_string(), file);
			}