EmberJS - 使用自定义 layout/template 而不是 applcation.hbs
EmberJS - Using a custom layout/template instead of applcation.hbs
作为一周前开始使用 EmberJS 的 Rails 开发人员,我想知道是否可以使用自定义布局而不是提供的 applictaion.hbs?
就像我们在 rails 中做的那样:
class MyController < ApplicationController
layout :resolve_layout
# ...
确实可以,但你必须在视图中覆盖它,而不是在控制器中。您正在寻找 templateName
property that will allow you to override the default template. You might also want to look at the layoutName
property, since it's closely related. (You can read about the difference here.)
App.ApplicationView = Ember.View.extend({
templateName: 'something_other_than_application'
});
或者,如果您使用的是 Ember CLI:
// app/views/application.js
export default Ember.View.extend({
templateName: 'something_other_than_application'
});
作为一周前开始使用 EmberJS 的 Rails 开发人员,我想知道是否可以使用自定义布局而不是提供的 applictaion.hbs? 就像我们在 rails 中做的那样:
class MyController < ApplicationController
layout :resolve_layout
# ...
确实可以,但你必须在视图中覆盖它,而不是在控制器中。您正在寻找 templateName
property that will allow you to override the default template. You might also want to look at the layoutName
property, since it's closely related. (You can read about the difference here.)
App.ApplicationView = Ember.View.extend({
templateName: 'something_other_than_application'
});
或者,如果您使用的是 Ember CLI:
// app/views/application.js
export default Ember.View.extend({
templateName: 'something_other_than_application'
});