Ember的模板渲染管道

时间:2014-07-16 19:16:04

标签: javascript ember.js

我有一个主要应用程序和面向公众的页面的特定模板。基于文档,下面的代码是我认为应该工作的。但是我不断发出Cannot read property 'connectOutlet' of undefined错误。

router.js

Router.map(function() {
  this.route('app');
  this.route('login');
});

application.hbs

{{outlet}}

public.hbs

This is the public template
{{outlet}}

app.hbs

This is the app template
{{outlet}}

login.hbs

<input type="email" ...>
<input type="password" ...>

路由/ login.js

import Ember from "ember";

export default Ember.Route.extend({
  renderTemplate: function() {
    this.render('login', { into: 'public' });
  }
});

路由/ app.js

import Ember from "ember";

export default Ember.Route.extend({
  renderTemplate: function() {
    this.render('login', { into: 'public' });
  }
});

如果删除{into:..}选项,则不会抛出任何错误,但登录和应用模板都会呈现在应用程序模板中,而不是分别呈现为公共和应用程序。

我完全误解了Ember如何处理渲染?

1 个答案:

答案 0 :(得分:0)

在我正在使用ember的应用程序中,我还使用renderTemplate挂钩将模板呈现为另一个,您的代码与我的相同,看起来很好。

我认为问题可能是没有任何公共路线。我认为,如果你在路由器中定义一个,然后再试一次,它可能会工作。在我看来它无法将模板呈现为公共因为公共不存在。

相关问题