2
votes

Is there any way to reference an Ember view in the handlebars view helper without using the Ember Application global var? I'm getting the error below after precompiling my handlebars templates and minifying my Ember code using Grunt. This seems to be because the Ember global var is shortened to 'a' where the Handlebars template still refers to 'App.View'.

MyView.hbs:

{{#each controller}}
  {{view App.MyChildView}}
{{/each}}

MyChildView.hbs:

<div>Irrelevant HTML</div>

JS:

App = Ember.Application.Create();  
App.MyView = Ember.View.extend({...

App.MyChildView = Ember.View.extend({...

Error:

Uncaught Error: assertion failed: Unable to find view at path 'MyChildView'


Solution:

Found a solution to this by using the render helper instead of view.

MyView.hbs:

{{#each controller}}
  {{render "MyChildView"}}
{{/each}}
1
can you show more code on how your App.MyView is setup, template etc. - intuitivepixel
I think that's a better representation of my problem. I'm using a simplification of my program. - Michael Stone
So I think I found a resolution for this by using the {{render}} helper instead of {{view}}. Can't post it as an answer because you need 10 rep to answer your own question within 8 hours of posting it :( - Michael Stone
glad you found a solution, maybe you could edit your answer adding the solution. - intuitivepixel

1 Answers

1
votes

The handlebars {{view}} helper can accept a string instead of a constant. So try:

{{#each controller}}
  {{view "App.MyChildView"}}
{{/each}}