Skip to content

Instantly share code, notes, and snippets.

@mzgoddard
Created April 23, 2015 03:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mzgoddard/44548ee8dbae8cb90cad to your computer and use it in GitHub Desktop.
Save mzgoddard/44548ee8dbae8cb90cad to your computer and use it in GitHub Desktop.
Example ember-loader configuration to add handlebar helper loading.
// src/initializers/helper.js
exports.name = 'helper';
exports.initialize = function(container, app) {
Object.keys(app.HELPERS).forEach(function(key) {
Ember.Handlerbars.helper(key.replace(/\//g, '-'), app.HELPERS[key]);
});
};
module.exports = {
ember: {
// typeOrder currently has to specify all the types you want to include in
// your application automatically.
typeOrder: [
'component',
'model',
'template',
'initializer',
'helper',
'router',
'controller',
'route',
'view',
'style',
'css',
'less',
'sass',
'stylus'
],
types: {
helper: {
store: function(params) {
var match = /^helpers\/(.*)$|^(.*)[-_/]helper$/.exec(params.name);
if (match) {
module.HELPERS = module.HELPERS || {};
module.HELPERS[match[1] || match[2]] = params.fullpath;
return module;
}
},
extend: function(merged, auto, manual) {
merged.HELPERS = auto.HELPERS || {};
return Ember.$.extend(merged.HELPERS, auto.HELPERS, manual.HELPERS);
},
},
},
},
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment