Javascript EmberJS:渲染默认模板

Javascript EmberJS:渲染默认模板,javascript,templates,ember.js,handlebars.js,ember-cli,Javascript,Templates,Ember.js,Handlebars.js,Ember Cli,我正在尝试构建一个Ember应用程序,我希望将嵌套路由的默认模板呈现到索引路由中。这是router.js export default Router.map(function() { this.route('posts', function() { this.route('featured'); this.route('authors'); this.route('popular'); }); }); 以下是posts index.hbs模板: <div

我正在尝试构建一个Ember应用程序,我希望将嵌套路由的默认模板呈现到索引路由中。这是
router.js

export default Router.map(function() {
  this.route('posts', function() {
    this.route('featured');
    this.route('authors');
    this.route('popular');
  });
});
以下是
posts index.hbs
模板:

<div class="posts">
  <h2>Welcome to your blog posts</h2>
  <p>Here are your posts:</p>
  <ul>
    <li>{{#link-to 'posts.featured'}}Featured{{/link-to}}</li>
    <li>{{#link-to 'posts.authors'}}Authors{{/link-to}}</li>
    <li>{{#link-to 'posts.popular'}}Popular{{/link-to}}</li>
  </ul>
  <div class="posts-container">
    {{outlet}}
  </div>
</div>
<div class="featured-posts">
  <h3>List of featured posts</h3>
  <p>...</p>
</div>
其他模板与
特色
模板相同

正如您在上面的应用程序中所看到的,我希望当用户访问
/posts
时,他们将看到
posts index
模板,以及默认呈现的
posts/featured.hbs
模板。当然,用户仍然可以导航到url
/posts/featured
,并看到相同的内容


对此的任何建议都将不胜感激。谢谢

Ember
Route
提供了一个钩子,您可以这样使用:

App.PostsIndexRoute = Em.Route.extend({

  renderTemplate: function() {
    // renders the template for the current route, as per conventions
    // in your case it will be 'posts/index' 
    this.render();

    // renders the named template 'posts/feature' *into* another named template
    this.render('posts/featured', {
      into: 'posts/index' // which in this case is 'posts/index'
    }); 
  }
});

(请参阅)

谢谢您的快速提示。这就是我真正想要完成的。