Search code examples
javascriptcoffeescriptsprocketsmiddleman

sprockets dont want to compile valid coffee script


@element.stop().animate
  scrollLeft: @left
  scrollTop:  @top
, @options.duration, "linear"

it compiles in online interpreter (coffeescript.org) to:

this.element.animate({
  scrollLeft: this.left,
  scrollTop: this.top
}, this.options.duration, "linear");

But middleman (it uses sprockets) throws an exception about "." in "@options.duration":

Uncaught Error: ExecJS::ProgramError: Error: Parse error on line 131:
Unexpected '.' (in */source/javascripts/views/scene.js.coffee) application.js:1
(anonymous function)

I am new to coffee script. Does it look like bug in sprockets?


Solution

  • That error could happen if you're accidentally mixing tabs and spaces in your CoffeeScript. You probably won't be able to see the problem with your eyes and the copy/paste you're doing to check your work at coffeescript.org could convert the tab to spaces behind your back.