Support for defining components within plugins

This commit is contained in:
Robin Ward 2014-05-16 15:54:28 -04:00
parent 09dc3f128f
commit aa9e89b6c8
1 changed files with 7 additions and 3 deletions

View File

@ -47,10 +47,14 @@ Discourse.Resolver = Ember.DefaultResolver.extend({
},
customResolve: function(parsedName) {
var moduleName = 'discourse/' + parsedName.type + 's/' + parsedName.fullNameWithoutType,
module = requirejs.entries[moduleName];
// If we end with the name we want, use it. This allows us to define components within plugins.
var suffix = parsedName.type + 's/' + parsedName.fullNameWithoutType,
moduleName = Ember.keys(requirejs.entries).find(function(e) {
return e.indexOf(suffix, e.length - suffix.length) !== -1;
});
if (module) {
var module;
if (moduleName) {
module = require(moduleName, null, null, true /* force sync */);
if (module && module['default']) { module = module['default']; }
}