Ember.js 余烬/把手:自定义辅助对象渲染
在我的自定义辅助对象中,如何呈现本身使用辅助对象(在本例中为“操作”辅助对象)的按钮?我正在尝试这个:Ember.js 余烬/把手:自定义辅助对象渲染,ember.js,handlebars.js,Ember.js,Handlebars.js,在我的自定义辅助对象中,如何呈现本身使用辅助对象(在本例中为“操作”辅助对象)的按钮?我正在尝试这个: Ember.Handlebars.registerBoundHelper('actionButtons', function(context, options) { return new Handlebars.SafeString("<button {{action 'remove'}} class='destroy'>Delete</button>"); }
Ember.Handlebars.registerBoundHelper('actionButtons', function(context, options) {
return new Handlebars.SafeString("<button {{action 'remove'}} class='destroy'>Delete</button>");
}
Ember.handlebar.registerBoundHelper('actionButtons',函数(上下文,选项){
返回新把手。安全字符串(“删除”);
}
但是我得到的只是一个格式不正确的html的无效按钮。在这个问题上,您可能希望使用分部而不是助手
{{partial 'buttons'}}
或者你可以
Ember.Handlebars.helper('actionButtons', Ember.View.extend({
templateName: 'buttons'
}));
{{actionButtons}}
Ember.Handlebars.helper('actionButtons', Ember.View.extend({
template: Ember.Handlebars.compile('<button {{action 'remove'}} class='destroy'>Delete</button>')
}));
{{actionButtons}}
模板的内容如下
<button {{action 'remove'}} class='destroy'>Delete</button>
删除
或者你可以
Ember.Handlebars.helper('actionButtons', Ember.View.extend({
templateName: 'buttons'
}));
{{actionButtons}}
Ember.Handlebars.helper('actionButtons', Ember.View.extend({
template: Ember.Handlebars.compile('<button {{action 'remove'}} class='destroy'>Delete</button>')
}));
{{actionButtons}}
Ember.handlebar.helper('actionButtons',Ember.View.extend({
模板:Ember.handlebar.compile('Delete')
}));
{{actionButtons}}
if(context.content.get('userID')==App.currentUser.get('id')){return handlebar.compile(“Delete”);}如果呈现取决于某个求值为true的语句,该怎么办