-
-
Save pvmsikrsna/ad01c5d6e2a764e0cd59ff8a994197af to your computer and use it in GitHub Desktop.
Ember Directives component-lookup override
This file contains hidden or 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
import Ember from 'ember'; | |
export default Ember.Object.extend({ | |
lookupFactory: function(name, container) { | |
container = container || this.container; | |
var fullName = 'component:' + name, | |
templateFullName = 'template:components/' + name, | |
templateRegistered = container && container.has(templateFullName); | |
if (templateRegistered) { | |
container.injection(fullName, 'layout', templateFullName); | |
} | |
var Component = container.lookupFactory(fullName); | |
if (!Component) { | |
var Directive = container.lookupFactory('directive:'+name); | |
if (Directive) { | |
container.register(fullName, Ember.Component.extend(Directive)); | |
Component = container.lookupFactory(fullName); | |
} | |
} | |
// Only treat as a component if either the component | |
// or a template has been registered. | |
if (templateRegistered || Component) { | |
if (!Component) { | |
container.register(fullName, Ember.Component); | |
Component = container.lookupFactory(fullName); | |
} | |
return Component; | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment