Is it possible to use haml within a coffeescript file in a rails 3.1 project?
What is the correct order of the file extensions?
My last try was that:
home.js.haml.coffescript
$ ->
alert '#{@count}'
where @count is a ruby variable.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The correct order would be
home.js.coffeescript.haml—you want the file to first be evaluated as Haml to give you your variables, then compiled as CoffeeScript, then finally served as JavaScript.However, I strongly suspect that the Haml processor will choke on some CoffeeScript syntax. It would probably be safer to use ERB, which should work for your example.