Skip to content

Commit

Permalink
allow handlebars sprig in content markdown files
Browse files Browse the repository at this point in the history
Signed-off-by: Rajat Jindal <rajatjindal83@gmail.com>
  • Loading branch information
rajatjindal committed Jun 5, 2023
1 parent 1440aa7 commit 258e7b3
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/content.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,13 +387,16 @@ impl Content {
// be rendered as HTML
handlebars.register_escape_fn(handlebars::no_escape);

// register the handlebars_sprig helpers
handlebars_sprig::addhelpers(&mut handlebars);

// run the markdown through the template engine to
// enable any script helpers
out = handlebars
.render_template(&self.body, &{})
.unwrap_or_else(|e| {
// print the error
eprintln!("Error rendering markdown: {e}");
eprintln!("Error rendering markdown: {:#?}", e);
// return nothing
e.to_string()
});
Expand Down

0 comments on commit 258e7b3

Please sign in to comment.