Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inline ruby in :javascript haml tag? [duplicate]

Hey is there a way I can do this in haml?

:javascript
   var Tab = <%= @tab %>

I could just add a helper I guess like:

<script>
  var Tab = '<%= @tab %>'
</script>

But it'd be nice to use HAML!

like image 776
Alex Fox Avatar asked Aug 19 '11 10:08

Alex Fox


1 Answers

You can use the string interpolation syntax (#{...}) :

:javascript
   var tab = #{@tab}

Take care of correctly escaping, however.

like image 52
Arnaud Le Blanc Avatar answered Oct 23 '22 10:10

Arnaud Le Blanc