diff --git a/src/lib.rs b/src/lib.rs index fae6b5c..f371df1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -289,14 +289,18 @@ fn render_markdown (content: &tera::Value, args: &HashMap) impl PageRenderer { pub fn new() -> PageRenderer { - let mut tera = tera::Tera::new("templates/**/*.html").unwrap(); + Self::with_template_path(DEFAULT_TEMPLATES_PATH) + } + + pub fn with_template_path(template_path: &str) -> PageRenderer { + let mut tera = tera::Tera::new(&format!("{template_path}/**/*.html")).unwrap(); tera.register_filter("markdown", render_markdown); PageRenderer { - template_root: DEFAULT_TEMPLATES_PATH.into(), + template_root: template_path.into(), tera } } - + pub fn render_page(&self, historian: &Historian, page: &Page, options: &Table) -> String { self.render_page_template("page.html", &historian, &page, &options) } diff --git a/src/main.rs b/src/main.rs index a55b2ec..06d2932 100644 --- a/src/main.rs +++ b/src/main.rs @@ -181,14 +181,24 @@ struct Args { /// Resolve all wiki links in the given page, output the modified text #[arg(long)] - resolve_links: Option + resolve_links: Option, + + /// Path to templates + #[arg(long)] + template_path: Option } #[rocket::main] async fn main() { let args = Args::parse(); let historian = Historian::new(args.wiki_path); - let renderer = PageRenderer::new(); + + let renderer = if let Some(template_path) = args.template_path { + PageRenderer::with_template_path(&template_path) + } else { + PageRenderer::new() + }; + let linker = Linker::new(&historian); if let Some(resolve_link) = args.resolve_link {