This is a terrible way to structure code.
Inline JavaScript is bad enough. Inline JavaScript with ERb inside puts you straight into hell.
JavaScript should be in external static files. That way the browser can cache them, and you can use JavaScript as a real programming language.
In your case, I'd recommend something like:
(Haml file)
#tab= @tab
(CSS file)
#tab { display: none }
(Javascript file)
var Tab = $('#tab').innerHTML();
That way everything stays static and maintainable, and you're not mixing JS and HTML.