Add support for custom template path.

This commit is contained in:
2024-09-27 05:03:02 -05:00
parent 9ae1022a21
commit 2198201713
2 changed files with 19 additions and 5 deletions

View File

@@ -289,14 +289,18 @@ fn render_markdown (content: &tera::Value, args: &HashMap<String, tera::Value>)
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)
}