ember-cli-htmlbars
Advanced tools
Comparing version 0.7.6 to 0.7.7
@@ -6,2 +6,3 @@ 'use strict'; | ||
var htmlbarsCompile = require('./index'); | ||
var utils = require('./utils'); | ||
@@ -31,4 +32,10 @@ module.exports = { | ||
toTree: function(tree) { | ||
var htmlbarsOptions = self.htmlbarsOptions(); | ||
return htmlbarsCompile(tree, htmlbarsOptions); | ||
}, | ||
return htmlbarsCompile(tree, self.htmlbarsOptions()); | ||
precompile: function(string) { | ||
var htmlbarsOptions = self.htmlbarsOptions(); | ||
var templateCompiler = htmlbarsOptions.templateCompiler; | ||
return utils.template(templateCompiler, string); | ||
} | ||
@@ -35,0 +42,0 @@ }); |
11
index.js
'use strict'; | ||
var utils = require('./utils'); | ||
var Filter = require('broccoli-filter'); | ||
@@ -43,15 +44,11 @@ | ||
if (FEATURES && templateCompiler) { | ||
for (var feature in FEATURES) { | ||
templateCompiler._Ember.FEATURES[feature] = FEATURES[feature]; | ||
} | ||
} | ||
utils.initializeFeatures(templateCompiler, FEATURES); | ||
}; | ||
TemplateCompiler.prototype.processString = function (string, relativePath) { | ||
return 'export default Ember.HTMLBars.template(' + this.precompile(string, { | ||
return 'export default ' + utils.template(this.options.templateCompiler, string, { | ||
moduleName: relativePath | ||
}) + ');'; | ||
}) + ';'; | ||
}; | ||
module.exports = TemplateCompiler; |
{ | ||
"name": "ember-cli-htmlbars", | ||
"version": "0.7.6", | ||
"version": "0.7.7", | ||
"description": "A library for adding htmlbars to ember CLI", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -42,1 +42,23 @@ # Ember CLI HTMLBars | ||
``` | ||
### Precompile HTMLBars template strings within other addons | ||
```javascript | ||
module.exports = { | ||
name: 'my-addon-name', | ||
setupPreprocessorRegistry: function(type, registry) { | ||
var htmlbarsPlugin = registry.load('template').find(function(plugin) { | ||
return plugin.name === 'ember-cli-htmlbars'; | ||
}); | ||
// precompile any htmlbars template string via the precompile method on the | ||
// ember-cli-htmlbars plugin wrapper; `precompiled` will be a string of the | ||
// form: | ||
// | ||
// Ember.HTMLBars.template(function() {...}) | ||
// | ||
var precompiled = htmlbarsPlugin.precompile("{{my-component}}"); | ||
} | ||
}; | ||
``` |
@@ -40,3 +40,3 @@ 'use strict'; | ||
var source = fs.readFileSync(sourcePath + '/template.hbs', { encoding: 'utf8' }); | ||
var expected = 'export default Ember.HTMLBars.template(' + htmlbarsPrecompile(source) + ');'; | ||
var expected = 'export default Ember.HTMLBars.template(' + htmlbarsPrecompile(source, { moduleName: 'template.hbs' }) + ');'; | ||
@@ -58,3 +58,3 @@ assert.equal(actual,expected,'They dont match!'); | ||
var source = fs.readFileSync(sourcePath + '/web-component-template.hbs', { encoding: 'utf8' }); | ||
var expected = 'export default Ember.HTMLBars.template(' + htmlbarsPrecompile(source) + ');'; | ||
var expected = 'export default Ember.HTMLBars.template(' + htmlbarsPrecompile(source, { moduleName: 'web-component-template.hbs' }) + ');'; | ||
@@ -61,0 +61,0 @@ assert.equal(actual,expected,'They dont match!'); |
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
10314
15
181
64