Ember App Kit:找不到用于模板插座的viewClass

时间:2014-03-28 08:35:45

标签: ember.js handlebars.js ember-app-kit

我已经获得了application.hbs模板,其中我声明了多个{{outlet}} s(名为& unnamed)和一个具有指定viewClass属性的模板:

application.hbs

{{outlet 'modal'}}
{{outlet 'notification'}}
<h1>EAK Application</h1>
{{#view 'application/content'}}
  {{!some HTML markup, etc. }}

  {{outlet viewClass='application/content-container'}}
{{/view}}

我的视图文件放在

app/views/application/content.js
app/views/application/content-container.js

但是Ember App Kit找不到content-container视图!

  

未捕获错误:断言失败:无法在路径中找到视图   &#39;视图/应用/内容容器&#39;

我做错了吗?

修改


与此同时,我做了简单的解决方法,并将其称为

{{#view 'application/content-container'}}
  {{outlet}}
{{/view}}

但这给了我一个额外的<div>图层,并且不那么优雅了#34; IMHO ...

1 个答案:

答案 0 :(得分:1)

当前的Ember API参考(http://emberjs.com/api/classes/Ember.Handlebars.helpers.html#method_outlet)表示插座上的媒体资源应为view而不是viewClass

{{#view 'application/content'}}
  {{!some HTML markup, etc. }}

  {{outlet view='application/content-container'}}
{{/view}}

如果没有完全了解您的应用程序,我无法提出具体建议,但如果您想利用深层链接网址,则应尽可能使用路线将模板/视图分配给网点。

例如,您的IndexRoute将需要IndexTemplateIndexView(或将在幕后创建一个)。在Ember App Kit中,它们位于app/views/index.jsapp/templates/index.hbs。查看Ember网站上的Rendering a Template指南:http://emberjs.com/guides/routing/rendering-a-template/

或者您也可以使用视图助手,如:

{{view 'my-view'}}

与视图助手期望实际类的普通Ember view helper不同。在Ember App Kit中,它是基于app/views根目录中文件名和路径的文件路径。