我有以下CoffeeScript
Excelsior.TopicView = Ember.View.extend
templateName: 'topic',
didInsertElement :() ->
this._super()
Ember.run.scheduleOnce 'afterRender', this, ->
converter = new Markdown.Converter()
editor = new Markdown.Editor(converter)
editor.run()
它生成的javascript是
(function() {
Excelsior.TopicView = Ember.View.extend({
templateName: 'topic',
didInsertElement: function() {
var editor;
this._super();
Ember.run.scheduleOnce('afterRender', this, function() {
var converter;
return converter = new Markdown.Converter();
});
editor = new Markdown.Editor(converter);
editor.run();
}
});
}).call(this);
这是不正确的,我实际想要生成的是
(function() {
Excelsior.TopicView = Ember.View.extend({
templateName: 'topic',
didInsertElement: function() {
this._super();
Ember.run.scheduleOnce('afterRender', this, function() {
var converter= new Markdown.Converter();
var editor = new Markdown.Editor(converter);
editor.run();
});
}
});
}).call(this);
如何修复我的咖啡?
答案 0 :(得分:2)
你需要小心缩进(确保你没有混合空格和制表符):
Excelsior.TopicView = Ember.View.extend
templateName: 'topic',
didInsertElement :() ->
this._super()
Ember.run.scheduleOnce 'afterRender', this, ->
converter = new Markdown.Converter()
editor = new Markdown.Editor(converter)
editor.run()