ember-cli-htmlbars
Advanced tools
Comparing version 0.7.8 to 0.7.9
@@ -77,3 +77,3 @@ 'use strict'; | ||
isHTMLBars: true, | ||
FEATURES: EmberENV.FEATURES, | ||
EmberENV: EmberENV, | ||
templateCompiler: require(templateCompilerPath), | ||
@@ -80,0 +80,0 @@ |
@@ -41,6 +41,13 @@ 'use strict'; | ||
TemplateCompiler.prototype.initializeFeatures = function initializeFeatures() { | ||
var EmberENV = this.options.EmberENV; | ||
var FEATURES = this.options.FEATURES; | ||
var templateCompiler = this.options.templateCompiler; | ||
utils.initializeFeatures(templateCompiler, FEATURES); | ||
if (FEATURES) { | ||
console.warn('Using `options.FEATURES` with ember-cli-htmlbars is deprecated. Please provide the full EmberENV as options.EmberENV instead.'); | ||
EmberENV = EmberENV || {}; | ||
EmberENV.FEATURES = FEATURES; | ||
} | ||
utils.initializeEmberENV(templateCompiler, EmberENV); | ||
}; | ||
@@ -47,0 +54,0 @@ |
{ | ||
"name": "ember-cli-htmlbars", | ||
"version": "0.7.8", | ||
"version": "0.7.9", | ||
"description": "A library for adding htmlbars to ember CLI", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -29,6 +29,2 @@ 'use strict'; | ||
afterEach(function() { | ||
}); | ||
it('precompiles templates into htmlbars', function(){ | ||
@@ -47,3 +43,3 @@ var tree = templateCompilerFilter(sourcePath, htmlbarsOptions); | ||
it('passes FEATURES to compiler', function(){ | ||
it('passes FEATURES to compiler when provided as `FEATURES` [DEPRECATED]', function(){ | ||
htmlbarsOptions.FEATURES = { | ||
@@ -64,2 +60,22 @@ 'ember-htmlbars-component-generation': true | ||
}); | ||
it('passes FEATURES to compiler when provided as `EmberENV.FEATURES`', function(){ | ||
htmlbarsOptions.EmberENV = { | ||
FEATURES: { | ||
'ember-htmlbars-component-generation': true | ||
} | ||
}; | ||
var tree = templateCompilerFilter(sourcePath, 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(' + htmlbarsPrecompile(source, { moduleName: 'web-component-template.hbs' }) + ');'; | ||
assert.equal(actual,expected,'They dont match!'); | ||
}); | ||
}); | ||
}); |
26
utils.js
'use strict'; | ||
module.exports = { | ||
initializeFeatures: function(templateCompiler, FEATURES) { | ||
if (FEATURES && templateCompiler) { | ||
for (var feature in FEATURES) { | ||
templateCompiler._Ember.FEATURES[feature] = FEATURES[feature]; | ||
} | ||
initializeEmberENV: function(templateCompiler, EmberENV) { | ||
if (!templateCompiler || !EmberENV) { return; } | ||
var props; | ||
if (EmberENV.FEATURES) { | ||
props = Object.keys(EmberENV.FEATURES); | ||
props.forEach(function(prop) { | ||
templateCompiler._Ember.FEATURES[prop] = EmberENV.FEATURES[prop]; | ||
}); | ||
} | ||
if (EmberENV) { | ||
props = Object.keys(EmberENV); | ||
props.forEach(function(prop) { | ||
if (prop === 'FEATURES') { return; } | ||
templateCompiler._Ember.ENV[prop] = EmberENV[prop]; | ||
}); | ||
} | ||
}, | ||
@@ -11,0 +27,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12967
16
245