开发者

content_tag formatting to entities?

开发者 https://www.devze.com 2023-03-19 18:47 出处:网络
When I use content_tag, my t开发者_如何学Pythonags get converted to their HTML entity equivalent. The code I use is

When I use content_tag, my t开发者_如何学Pythonags get converted to their HTML entity equivalent. The code I use is

The view renders

Hello This is a <strong>test</strong>

When I'd like it to render

Hello This is a test

The content format of the database is text, which may or may not affect the output, since there are newlines and return carriages within the content.


You should tell Rails the content is safe. Two options:

  • your_content.html_safe

  • <%=raw your_content %>

0

精彩评论

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