Skip to content

Instantly share code, notes, and snippets.

@zeppelin
Created September 23, 2014 20:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save zeppelin/8885a0028dac6def57c7 to your computer and use it in GitHub Desktop.
Save zeppelin/8885a0028dac6def57c7 to your computer and use it in GitHub Desktop.
Ember Directives component-lookup override
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