On Rails 3.2.13, simple_format
does not return what I expect it to do, on an admittedly convoluted case:
> simple_format("a <= 2, b < 4")
"<p>a < 4</p>"
Since this case does not seem to work properly (I'm losing half my string!), is there a way to pre-escape special characters so that it works everywhere?
You could html_escape
the string yourself:
ERB::Util.h("a <= 2, b < 4")
#=> "a <= 2, b < 4"
simple_format(ERB::Util.h("a <= 2, b < 4"))
#=> "<p>a <= 2, b < 4</p>"
From within views, you can omit ERB::Util.
and just call h