I have the ruby code:
<%= "hello #{@namevar}" if condition %>
I can include ruby snippet in JS in the following way-
<script>
var v1="<%= @user.name %>"
</script>
But can't embed the previous code in JavaScript.
I have tried the following:
var v2="<%= \"hello #{@namevar}\" if condition %>";
But didn't work.
Thanx.
<%= "hello #{@namevar}" if condition %>to get into a JS variable