I have a javascript function (available on all pages as it's included in application.js) that detects if the browser has Flash support and outputs true or false.
Now, I want to show a flash based price chart if true and a HTML/Javascript based chart if false.
At the top of a Haml page I try to pass the result of the javascript function to HAML like this:
:javascript
if (browserHasFlashSupport())
#{showFlashChart = true}
And use it in Haml further down on the page like this:
- if showFlashChart
# show flash chart
- else
# show html/js chart
But I can't get it to work as the ruby variable showFlashChart is "true" no matter what - but in console, the javascript function browserHasFlashSupport() returns true/false like it should, so I must be doing something wrong.
I guess it would probably be the best solution just to use the javascript functions "return true/false" directly in HAML like - if browserHasFlashSupport() if that's possible and the "right" way to do it?
I'd appreciate any help, thanks :-)
PS. Any tips on how to avoid the usage of inline javascript in my HAML file would be very welcome too.
html??gon? github.com/gazay/gon