I'm using Sinatra, Ruby, HAML, and JavaScript
So I figured out how to call a ruby function in HAML JavaScript
@@layout
%html
%head
%title #{@title}
:javascript
var retval
function diff_by_company_id() {
retval = "#{ruby_function()}";
}
However I now need to pass the ruby function a javascript variable and I'm not sure how do it. This is what I tried that obviously doesn't work.
def test(input)
return "Output Number: "+input.to_s + "!"
end
@@layout
%html
%head
%title #{@title}
:javascript
var retval
function diff_by_company_id() {
var input = 1;
retval = "#{ruby_function("input")}";
}
instead of passing the value of input, 1, it passes in the string input.
So what i get is: retval = Output Number: input!
What I want is: retval = Output Number: 1!
Any help on how to pass this correctly would be appreciated.