Can I use CoffeeScript in the views executed on render.js?

后端 未结 4 1457
长发绾君心
长发绾君心 2021-02-07 20:18

What do I need to do so that I can use CoffeeScript in the Rails JS views? For example:

def index
    format.js { render :layout => false } 
end
4条回答
  •  遇见更好的自我
    2021-02-07 21:19

    if you dont want to install coffeebeans, heres a sort of quick and dirty way to do it by hacking into the erb outputter a bit :

    <% 
    require 'coffee-script'; 
    def coffee_script; CoffeeScript.compile yield '' end %>
    
    

提交回复
热议问题