0

I have the following 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()

And the javascript it generates is

(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);

This is not correct and what I actually want to generate is

(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);

How can I fix my coffeescript?

1
  • 1
    Your Coffee indentation is messed up. Commented May 23, 2014 at 23:25

1 Answer 1

2

You need to be careful with indent (make sure you're not mixing spaces and tabs):

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()
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.