0

I have a form in Ruby on Rails, that handles creation of a new comment asynchronous.

I use format.js as a response and my code in the template looks something like this:

create.js.haml

- if (@comment.position)
  -# add the comment to the video
  -# do smthng
  if (window.Test == true){
    -# do something else
  }


-# do other stuff

The problem is, that I get a Illegal nesting: nesting within plain text is illegal. Error for the line that contains //do something else.

I know, I could simply remove the indention of this line, but I want to format my JS code as usual.

Any ideas how I can do this correctly?

Thanks a lot!

Community
  • 1
  • 1
Sebastian
  • 1,873
  • 4
  • 25
  • 57
  • possible duplicate: http://stackoverflow.com/questions/9744169/include-inline-js-in-haml – Uri Agassi Dec 02 '14 at 10:48
  • wrong haml comment syntax fix to `-# add the comment to the video` and `-# do smthng` – Roman Kiselenko Dec 02 '14 at 11:20
  • No, its not a duplicate, because in this situation the code with `:javascript` would return a js file that would include a `` tag which would cause the response to fail, because this is no valid JavaScript file. – Sebastian Dec 02 '14 at 12:02

0 Answers0