RedCloth escaping HTML output
After watching this RailsCast, I thought I'd give RedCloth a try. Unfortunately, it looks like开发者_C百科 I'm having an issue that involves the resultant HTML being encodeded instead of rendered as straight HTML.
First I added the following to my Gemfile:
gem 'RedCloth', '4.2.7'
I added a basic RedCloth implementation to my view:
<%= RedCloth.new("* one\n* two\n * three").to_html %>
When I "view source" for the page that is rendered, this is what appears:
<ul> <li>one</li> <li>two</li> <li>three</li> </ul>
The output I expected was the following:
<ul> <li>one</li> <li>two</li> <li>three</li> </ul>
Am I doing something wrong? Do I need to pass a parameter to
to_html
or the RedCloth constructor?
Try this:
<%= raw RedCloth.new("* one\n* two\n * three").to_html %>
Also check out this blog post on the subject.
精彩评论