如何将内容呈现到由应用程序模板呈现的emberjs模板中?

How can I render content into an emberjs template that is rendered by the application template?

本文关键字:emberjs 应用程序      更新时间:2023-09-26

基本上我想做一些像Rails content_for的东西,视图的一部分在任何地方看起来都是一样的,但它的某些部分是不同的,这取决于你在网站的位置。

下面是我想要的一个例子:http://emberjs.jsbin.com/sikimayo/2/edit

如果你运行它并检查你的javascript错误,你会看到这个错误:

Cannot read property 'connectOutlet' of undefined

看起来foo-with-outlet不是一个活动视图,因为它是由应用程序模板呈现的,而不是当前路由。

虽然从消除每个子路由中的样板文件的角度来看并不理想,但这可以通过嵌套出口及其相关的呈现调用来实现。

参见JSBin http://emberjs.jsbin.com/sikimayo/4/edit