forked from ryedeer/ember-cli-markdown-templates
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
40 lines (31 loc) · 1.03 KB
/
index.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
/*jshint node:true*/
'use strict';
var Filter = require('broccoli-filter');
var Showdown = require('showdown');
var converter = new Showdown.Converter();
function MarkdownCompiler (inputTree, options) {
if (!(this instanceof MarkdownCompiler)) {
return new MarkdownCompiler(inputTree, options);
}
Filter.call(this, inputTree, options);
}
MarkdownCompiler.prototype = Object.create(Filter.prototype);
MarkdownCompiler.prototype.constructor = MarkdownCompiler;
MarkdownCompiler.prototype.extensions = ['md', 'markdown'];
MarkdownCompiler.prototype.targetExtension = 'hbs';
MarkdownCompiler.prototype.processString = function (string, relativePath) {
return converter.makeHtml(string);
}
module.exports = {
name: 'ember-cli-markdown-templates',
setupPreprocessorRegistry: function(type, registry) {
var compiler = {
name: 'ember-cli-markdown-templates',
ext: ['md', 'markdown'],
toTree: function(tree) {
return MarkdownCompiler(tree, {});
}
};
registry.add('template', compiler);
}
};