ibpix
ibpix

Reputation: 319

how to embed the result of a Ruby variable in a slim Javscript block

I have a Rails app that uses slim for templating. I'd like to have:

javascript: 
  window.ads.hasMap = ??? # value of show_map 

like in .erb

   window.ads.hasMap = <%=show_map %>;

How would I do this?

Upvotes: 0

Views: 167

Answers (1)

JohnP
JohnP

Reputation: 1309

According to the docs, it looks like you want:

javascript: 
  window.ads.hasMap = #{show_map}

That is, wrap your ruby variable or method in #{...}.

Upvotes: 1

Related Questions