forked from helpers/handlebars-helpers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
markdown.js
55 lines (49 loc) · 1.1 KB
/
markdown.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
'use strict';
/**
* Expose markdown `helpers` (for performance we're using getters so
* that the helpers are only loaded if called)
*/
var helpers = module.exports;
var markdown;
/**
* Block helper that converts a string of inline markdown to HTML.
*
* ```handlebars
* {{#markdown}}
* # Foo
* {{/markdown}}
* <!-- results in: <h1>Foo</h1> -->
* ```
* @name .markdown
* @param {Object} `context`
* @param {Object} `options`
* @return {String}
* @block
* @api public
*/
Object.defineProperty(helpers, 'markdown', {
configurable: true,
enumerable: true,
set: function(val) {
markdown = val;
},
get: function() {
// this is defined as a getter to avoid calling this function
// unless the helper is actually used
return markdown || (markdown = require('helper-for-markdown')());
}
});
/**
* Read a markdown file from the file system and inject its contents after
* converting it to HTML.
*
* ```handlebars
* {{md "foo/bar.md"}}
* ```
* @param {Object} `context`
* @param {Object} `options`
* @return {String}
* @block
* @api public
*/
helpers.md = require('helper-md');