Created
April 23, 2015 03:35
-
-
Save mzgoddard/44548ee8dbae8cb90cad to your computer and use it in GitHub Desktop.
Example ember-loader configuration to add handlebar helper loading.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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]); | |
}); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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