In Ruby on Rails, you can do it in several ways:
Use html_safe
to mark your HTML variable:
@alarms = "Hello <br/> World!".html_safe
document.getElementById("alarms_id").innerHTML = 'concat <%= @alarms %>';
Or use html_safe
to display your HTML variable:
@alarms = "Hello <br/> World!"
document.getElementById("alarms_id").innerHTML = 'concat <%= @alarms.html_safe %>';
Or use raw
to display your HTML variable:
@alarms = "Hello <br/> World!"
document.getElementById("alarms_id").innerHTML = 'concat <%=raw @alarms %>';
Notice that the alert()
function in JavaScript does not understand HTML code, so you cannot use it to display your HTML variable as is.