Skip to content

Commit

Permalink
add TemplateEngine
Browse files Browse the repository at this point in the history
  • Loading branch information
yuma140902 committed Oct 14, 2023
1 parent 2a9e3b9 commit 6b5dc8c
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/template_engine.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
use handlebars::Handlebars;

use crate::handlebars_helpers;

/// TemplateEngine is a wrapper for Handlebars and processes templates and [`Value`](crate::Value)s.
pub struct TemplateEngine(Handlebars<'static>);

impl TemplateEngine {
pub fn new() -> Self {
let mut handlebars = Handlebars::new();

handlebars.register_helper("md2html", Box::new(handlebars_helpers::md2html));
handlebars.register_helper("resolve", Box::new(handlebars_helpers::resolve));

Self(handlebars)
}
}

0 comments on commit 6b5dc8c

Please sign in to comment.