The reason for this is because the h() method escapes all the <
and >
The method works correctly, the tags should be escaped. Why do you want to unescape them?
If you don’t want to escape the output (because you actually want to output tags), simply don’t call h()
.
If you don’t have control over the calling of h()
, then you may mark your string as “HTML safe” by calling the appropriate method on your string before passing it to h()
. But it’s really hard to say if that’s appropriate for you:
s = "<strong>example</strong>".html_safe
h(s) # = "<strong>example</strong>"
Or:
s = "<strong>example</strong>"
s.html_safe!
h(s) # = "<strong>example</strong>"