Hello community,
I’m working on a project which is using ember 1.5.0. We developed a functionality to render dynamic content and works perfeclty (in Ember 1.5.0).
How it works
We have a helper which is called render-module.js
:
export default Ember.Handlebars.makeBoundHelper(function(module, options) {
options.types[0] = "STRING";
var container = options.data.keywords.controller.container;
var name = module.constructor.typeKey;
if (!container.lookup('view:' + name)) {
name = "module";
}
return Ember.Handlebars.helpers.render.call(this, name, "module", options);
});
A template which is called event.hbs
and here is where we call the rendering helper :
<div class="modules-holder event-screen">
<div {{bind-attr class=":modules-container view.columnsClass"}}>
{{#each module in currentLayout.modules}}
{{render-module module}}
{{/each}}
</div>
</div>
Finally we have differents views called <dynamic-module-name>-view
. So, the template will render each view given in the currentLayout.modules
array.
###Looking for a solution using Ember 1.9
We tried it a lot and we couldn’t find anything. Upgrading to Ember 1.9 will break the helper functionality. We also tried to implement a solution based on Dynamically render polymorphic component but with no results because we were able to render the views using that approach but the controllers (for that views) won’t be initialized.
Is there any approach to do this? We are stuck in it since two months ago.
Thanks a lot for reading this, we will be really thanksful if somebody could give us a hand !
Juan.