Last active
August 29, 2015 14:11
-
-
Save knownasilya/ca676c38f90d70753ec5 to your computer and use it in GitHub Desktop.
ember plugins
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
var pluginIds = Ember.keys(this.container.registry.dict).filter(function (item) { | |
return item && item.indexOf('plugin:') === 0; | |
}); | |
var containerView = Ember.ContainerView.create({ | |
}); | |
pluginIds.forEach(function (id) { | |
var factory = self.container.lookupFactory(id); | |
var view = factory.view.create(); | |
containerView.pushObject(view); | |
}); |
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
var MyPlugin = { | |
view: Ember.View.extend({ | |
templateName: 'plugins/my' | |
}) | |
}; | |
Ember.Application.initializer({ | |
name: 'my-plugin', | |
initialize: function(container, application) { | |
application.register('template:plugins/my', yourTemplate); | |
application.register('plugin:my', MyPlugin, { instantiate: false }); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment