ember-cli-htmlbars
Advanced tools
Comparing version
@@ -8,4 +8,12 @@ 'use strict'; | ||
included: function (app) { | ||
var HTMLBars = app.project.config(app.env).EmberENV.FEATURES['ember-htmlbars']; | ||
var projectConfig = app.project.config(app.env); | ||
var htmlbarsEnabled = projectConfig.EmberENV.FEATURES['ember-htmlbars']; | ||
var htmlbarsComponentGeneration = projectConfig.EmberENV.FEATURES['ember-htmlbars-component-generation']; | ||
if (htmlbarsEnabled) { | ||
var htmlbarsOptions = { | ||
disableComponentGeneration: htmlbarsComponentGeneration !== true | ||
}; | ||
} | ||
this._super.included.apply(this, arguments); | ||
@@ -20,3 +28,3 @@ | ||
toTree: function(tree) { | ||
return htmlbarsCompile(tree, { HTMLBars: HTMLBars }); | ||
return htmlbarsCompile(tree, { htmlbarsOptions: htmlbarsOptions }); | ||
} | ||
@@ -23,0 +31,0 @@ }) |
@@ -14,3 +14,5 @@ var Filter = require('broccoli-filter'); | ||
this.HTMLBars = options && options.HTMLBars || this.HTMLBars; | ||
this.options = options || {}; | ||
this.htmlbarsOptions= this.options.htmlbarsOptions; | ||
this.inputTree = inputTree; | ||
@@ -24,4 +26,4 @@ } | ||
TemplateCompiler.prototype.processString = function (string, relativePath) { | ||
if (this.HTMLBars) { | ||
return "var template = " + compileSpec(string) + "\nexport default Ember.HTMLBars.template(template);"; | ||
if (this.htmlbarsOptions) { | ||
return "export default Ember.HTMLBars.template(" + compileSpec(string, this.htmlbarsOptions) + ");"; | ||
} else { | ||
@@ -28,0 +30,0 @@ var input = handlbarsTemplateCompiler.precompile(string, false); |
{ | ||
"name": "ember-cli-htmlbars", | ||
"version": "0.2.5", | ||
"version": "0.3.0", | ||
"description": "A library for adding htmlbars to ember CLI", | ||
@@ -34,4 +34,4 @@ "main": "index.js", | ||
"ember-template-compiler": "^1.9.0-alpha", | ||
"htmlbars": "0.1.5" | ||
"htmlbars": "0.1.7" | ||
} | ||
} |
@@ -21,13 +21,36 @@ 'use strict'; | ||
it('precompiles templates into htmlbars', function(){ | ||
var tree = templateCompilerFilter(sourcePath, { HTMLBars: true }); | ||
describe('HTMLBars', function() { | ||
var htmlbarsOptions; | ||
builder = new broccoli.Builder(tree); | ||
return builder.build().then(function(results) { | ||
var actual = fs.readFileSync(results.directory + '/template.js', { encoding: 'utf8'}); | ||
var source = fs.readFileSync(sourcePath + '/template.hbs', { encoding: 'utf8' }); | ||
var expected = "var template = " + htmlbarsCompiler(source) + "\nexport default Ember.HTMLBars.template(template);"; | ||
beforeEach(function() { | ||
htmlbarsOptions = { | ||
disableComponentGeneration: true | ||
}; | ||
}); | ||
assert.equal(actual,expected,'They dont match!') | ||
it('precompiles templates into htmlbars', function(){ | ||
var tree = templateCompilerFilter(sourcePath, { htmlbarsOptions: htmlbarsOptions }); | ||
builder = new broccoli.Builder(tree); | ||
return builder.build().then(function(results) { | ||
var actual = fs.readFileSync(results.directory + '/template.js', { encoding: 'utf8'}); | ||
var source = fs.readFileSync(sourcePath + '/template.hbs', { encoding: 'utf8' }); | ||
var expected = "export default Ember.HTMLBars.template(" + htmlbarsCompiler(source) + ");"; | ||
assert.equal(actual,expected,'They dont match!') | ||
}); | ||
}); | ||
it('passes provided options to htmlbars', function(){ | ||
var tree = templateCompilerFilter(sourcePath, { htmlbarsOptions: htmlbarsOptions }); | ||
builder = new broccoli.Builder(tree); | ||
return builder.build().then(function(results) { | ||
var actual = fs.readFileSync(results.directory + '/web-component-template.js', { encoding: 'utf8'}); | ||
var source = fs.readFileSync(sourcePath + '/web-component-template.hbs', { encoding: 'utf8' }); | ||
var expected = "export default Ember.HTMLBars.template(" + htmlbarsCompiler(source, htmlbarsOptions) + ");"; | ||
assert.equal(actual,expected,'They dont match!') | ||
}); | ||
}); | ||
}); | ||
@@ -52,3 +75,3 @@ | ||
it('precompiles templates into handlebars when HTMLBars option is false', function(){ | ||
var tree = templateCompilerFilter(sourcePath, { HTMLBars: false }); | ||
var tree = templateCompilerFilter(sourcePath, { htmlbarsOptions: false }); | ||
@@ -55,0 +78,0 @@ builder = new broccoli.Builder(tree); |
6175
24.5%9
12.5%114
29.55%+ Added
- Removed
Updated