May 09, 2021 Ember.js Reference documents
Another important responsibility of routing is to render templates with the same name.
For example, the following routing
posts
route
posts.hbs
new
rendering
posts/new.hbs
Router.map(function() {
this.route('posts', function() {
this.route('new');
});
});
Each template is rendered on the parent
{{outlet}}
F
or example, the above
posts.hbs
is rendered on
application.hbs
{{outlet}}
application.hbs
the parent template for all custom templates.
The template posts/new.hbs is rendered on
posts.hbs
{{outlet}}
It is also allowed if you want to render to another template, but override
renderTemplate
in the route.
// app/routes/posts.js
import Ember from 'ember';
export default Ember.Route.extend({
// 渲染到favorites模板上
renderTemplate: function() {
this.render('favorites');
}
});
The rendering of the template is relatively simple, the content is also very small, in the previous Ember.js Getting Started Guide fourteer times outside, routing, template execution, rendering order has been introduced related to the content.
The full code of the blog post
is placed in Github
(the blog post has been modified several times, and the code on the blog post may be different from the github code, but the impact is small!). I
f you think the blog post is a bit useful to you, please give me a star on the
star
project.
Yours is definitely the biggest motivation for me!!