开发者

HTML line break within flash error?

开发者 https://www.devze.com 2023-04-01 16:44 出处:网络
I have a flash[:error] with an html line break. When it gets displayed, it literally show <br /> instead of interpreting it as html and breaking. Heres my error:

I have a flash[:error] with an html line break. When it gets displayed, it literally show <br /> instead of interpreting it as html and breaking. Heres my error:

  flash[:error] = "Format of search criteria is wrong.<br />Should be [
IXLSpecClass value开发者_高级运维][year]-[Message ID] for example GP07-8"


Yup. Since strings in Rails 3 (you're in Rails 3, right?) are escaped by default, you'd need to go into your template and instead of flash[:error] you would need to print flash[:error].html_safe in order to have it avoid automatic escaping.


That is because if you view the source it probably looks like this:

<br /> or to put it simply: &lt;br /&gt;

This is because the html was probably escaped at some point down the line.

0

精彩评论

暂无评论...
验证码 换一张
取 消