Skip to content

Commit

Permalink
Proof of concept
Browse files Browse the repository at this point in the history
  • Loading branch information
samselikoff committed Nov 18, 2015
1 parent 78038a3 commit 34b0dea
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@
"white": false,
"eqnull": true,
"esnext": true,
"unused": true
"unused": "vars"
}
53 changes: 52 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,57 @@
/* jshint node: true */
'use strict';

var Filter = require('broccoli-filter');
var marked = require('marked');
marked.setOptions({
gfm: true,
sanitize: true
});

function TemplateCompiler(inputNode, options) {
if (!(this instanceof TemplateCompiler)) {
return new TemplateCompiler(inputNode, options);
}

options = options || {};
Filter.call(this, inputNode, options);
this.compile = marked;
}

TemplateCompiler.prototype = Object.create(Filter.prototype);
TemplateCompiler.prototype.constructor = TemplateCompiler;
TemplateCompiler.prototype.extensions = ['md'];
TemplateCompiler.prototype.targetExtension = 'hbs';

TemplateCompiler.prototype.processString = function(string, relativePath) {
return this.compile(string).replace(/{/g, '{');
};

module.exports = {
name: 'ember-cli-markdown-compiler'
name: 'ember-cli-markdown-compiler',

isDevelopingAddon: function() {
return true;
},

setupPreprocessorRegistry: function(type, registry) {
registry.add('template', {
name: 'ember-cli-markdown-compiler',
ext: ['md'],
toTree: function(tree) {
return TemplateCompiler(tree);
}
});

if (type === 'parent') {
this.parentRegistry = registry;
}
},

included: function(app) {
this._super.included.apply(this, arguments);

this.setupPreprocessorRegistry('parent', app.registry);
}

};
16 changes: 11 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ember-cli-markdown-compiler",
"version": "0.0.0",
"description": "The default blueprint for ember-cli addons.",
"version": "1.0.0",
"description": "Build-time Markdown compiler for template.md -> template.hbs",
"directories": {
"doc": "doc",
"test": "tests"
Expand Down Expand Up @@ -41,9 +41,15 @@
"ember-addon"
],
"dependencies": {
"ember-cli-babel": "^5.1.3"
"broccoli-filter": "^1.2.2",
"ember-cli-babel": "^5.1.3",
"marked": "0.3.5"
},
"ember-addon": {
"configPath": "tests/dummy/config"
"configPath": "tests/dummy/config",
"before": [
"ember-cli-htmlbars"
]

}
}
}

0 comments on commit 34b0dea

Please sign in to comment.