سؤال

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.

هل كانت مفيدة؟

المحلول

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top