Drew
Drew

Reputation: 2663

Coffeescript invalid syntax

Thoughts on why the following is invalid syntactically?

@foo(@bar('/test', {
      password
      username
      _method: 'GET'
    }
  )
)

Upvotes: 0

Views: 27

Answers (1)

suish
suish

Reputation: 3363

The problem is the indentation.

The second parenthesis couldn't be read properly. If you make an indent explicitly for it, it work.

@foo(
  @bar('/test', {
      password
      username
      _method: 'GET'
    }
  )
)

Or remove indentation of the closing parenthesis.

@foo(@bar('/test', {
    password
    username
    _method: 'GET'
  }
))

both of them works as

this.foo(this.bar('/test', {
  password: password,
  username: username,
  _method: 'GET'
}));

Upvotes: 1

Related Questions