Skip to content

Latest commit

 

History

History
133 lines (89 loc) · 2.86 KB

README.md

File metadata and controls

133 lines (89 loc) · 2.86 KB

helper-markdown NPM version

Markdown template helper. Uses remarkable to render markdown in templates. Should work with Handlebars, Lo-Dash or any template engine that supports helper functions.

Usage examples

With Handlebars:

<div>
{{#markdown}}
# Heading

> this is markdown

foo bar baz
{{/markdown}}
</div>

Results in:

<h1>Heading</h1>
<blockquote>
<p>this is markdown</p>
</blockquote>
<p>foo bar baz</p>

Install with npm

npm i helper-markdown --save

Register the helper

This should work with any engine, here are a few examples

Register the helper for use with any template engine

template.helper('markdown', require('helper-markdown'));

To register the helper for use with assemble v0.6.x:

assemble.helper('markdown', require('helper-markdown'));

Register the helper for use with verb:

var verb = require('verb');
verb.helper('markdown', require('helper-markdown'));
var handlebars = require('handlebars');
handlebars.registerHelper('markdown', require('helper-markdown'));
var markdown = require('helper-markdown');

// as a mixin
_.mixin({markdown: markdown});
_.template('<%= _.markdown("# heading") %>', {});
//=> '<h1>heading</h1>\n'

// passed on the context
_.template('<%= markdown("# heading") %>', {markdown: markdown});
//=> '<h1>heading</h1>\n'

// as an import
var settings = {imports: {markdown: markdown}};
_.template('<%= markdown("# heading") %>', {}, settings);
//=> '<h1>heading</h1>\n'

Run tests

npm test

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue

To request or contribute a helper to the github.com/helpers org, please read this contributing guide to get started.

Author

Jon Schlinkert

License

Copyright (c) 2014 Jon Schlinkert
Released under the MIT license


This file was generated by verb on December 11, 2014. To update, run npm i -g verb && verb.