Crates.io | handlebars-markdown-helper |
lib.rs | handlebars-markdown-helper |
version | 0.7.0 |
source | src |
created_at | 2015-11-13 01:42:26.538553 |
updated_at | 2018-07-23 15:23:53.233625 |
description | A helper for handlebars that adds markdown rendering |
homepage | https://github.com/waynenilsen/handlebars-markdown-helper |
repository | |
max_upload_size | |
id | 3404 |
size | 63,988 |
The handlebars crate provides easy templating for any file type. This crate provides a helper for rendering a variable containing markdown into HTML within a temlpate.
extern crate handlebars_markdown_helper;
use handlebars_markdown_helper;
let mut handlebars = Handlebars::new();
handlebars.register_helper("markdown", Box::new(handlebars_markdown_helper::markdown_helper));
handlebars.register_template("t0", "{{markdown x}}");
let mut m :BTreeMap<String, String> = BTreeMap::new();
m.insert("x".into(), "# wow\n\n## second wow".into());
let r0 = handlebars.render("t0", &m);
assert_eq!(r0.ok().unwrap(), "<h1>wow</h1>\n<h2>second wow</h2>\n".to_string());