slim-lang

How to access instance variables in CoffeeScript engine inside a Slim template

烈酒焚心 提交于 2019-11-27 06:36:10
I have a Rails controller in which I am setting a instance variable - @user_name = "Some Username" In my .slim template I am using coffee engine to generate javascript and want to print out the user name from client-sie javascript code - coffee: $(document).ready -> name = "#{@user_name}" alert name But this is the javascript that is being generated?? $(document).ready(function() { var name; name = "" + this.my_name; alert(name); } How do I access controller instance variables in my CoffeeScript code?? I am tagging this as haml since I am guessing haml will have the same issue when using