鉴于这些模板
<script type="text/x-handlebars">
<h3>Application outlet:</h3>
<div class="outlet">
{{outlet}}
<div>
<h3><code>'base'</code> outlet:</h3>
<div class="outlet base-outlet">
{{outlet 'base'}}
</div>
</script>
<script type="text/x-handlebars" data-template-name="index">
<h1>I am the application index, I should be in the application outlet.</h1>
</script>
<script type="text/x-handlebars" data-template-name="foo">
<p>I am foo, I have my own outlet here:</p>
<h3>Foo Outlet:</h3>
<div class="outlet foo-outlet">
{{outlet}}
</div>
</script>
<script type="text/x-handlebars" data-template-name="foo/index">
<p>I am foo index, I should be inside <code>#foo-outlet</code> (green border)</p>
</script>
这些路线:
App.Router.map(function() {
this.resource('foo', function() {
this.resource('bar');
});
});
App.IndexRoute = Ember.Route.extend({
afterModel: function() {
this.transitionTo('foo.index');
}
});
App.FooRoute = Ember.Route.extend({
renderTemplate: function() {
this.render({into: 'application', outlet: 'base'});
}
});
我希望foo/index
模板可以在{{outlet}}
模板中包含的foo
内呈现,但是它会呈现在应用程序插座中,这里有一个实例:{ {3}}
请注意,如果我在this._super()
中拨打renderTemplate
,我会在正确的位置获得foo/index
种类,但foo
模板会呈现两次。
更新:我想要实现的目标如下:
'sidebar'
因此,在上面的示例中,foo
路由应该将其包装器呈现到'base'
出口,然后应该在其中呈现其子路由(示例中为foo/index
)的内容包装器内的插座(示例中具有类foo-outlet
的插座)。