2

Does Ember allow rendering dynamic views or only static, where I need to know name of template/controller used?

For example:

{{render view.processStep.filterForm model}}

and view.processStep.filterForm could be mapped to specific template and controller. Using such statement throws Exception:

Uncaught Error: Assertion Failed: You used `{{render 'view.processStep.filterForm'}}`, but 'view.processStep.filterForm' can not be found as either a template or a view.

1 Answers1

2

While I was unable to render a template name with a dynamic input, this is another option. This could be useful for you under the right circumstances, I actually was unable to use this for my own app, and would like the dynamic ability, but here is what I got for you.

http://emberjs.jsbin.com/sixin/2/edit

This jsbin shows you what I've done, if you have any questions let me know, but essentially you would need to use an outlet instead, and render your dynamic template into the outlet.

bmeyers
  • 734
  • 4
  • 8
  • 1
    Thanks, this is nice solution. I am using very similar to render modals and popups. Meanwhile I found `Ember.Handlebars.makeBoundHelper` method to register custom helper. `Ember.Handlebars.makeBoundHelper(function(name, contextString, options) { if (!name) { return new Ember.Handlebars.SafeString(''); } return Ember.Handlebars.helpers.render.apply(this, arguments); });` – user3679306 May 28 '14 at 06:49
  • Very nice, glad I could help – bmeyers May 28 '14 at 16:05
  • Hi @bmeyers I have one issue. I have some templates in which the data is loading dynamically. Each template is working fine separately. Now I want to get all that templates in a single page or want to store it for other purpose. – Rahul_Dabhi May 12 '15 at 07:24
  • @Rahul_Dabhi if I understand correctly, the problem you are having is that you don't want to load each file separately... In this case it is very common to precompile the templates and load them all at once. May I suggest using ember-cli? And if you don't want to use that, do you have a current build process setup? – bmeyers May 13 '15 at 12:43
  • @bmeyers Yes I have build process setup, For more information you may check these question http://stackoverflow.com/questions/30053762/ember-js-load-multiple-template-on-one-page-with-data – Rahul_Dabhi May 13 '15 at 12:45