开发者

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.

  1. First I added the following to my Gemfile:

    gem 'RedCloth', '4.2.7'
    
  2. I added a basic RedCloth implementation to my view:

    <%= RedCloth.new("* one\n* two\n * three").to_html %>
    
  3. When I "view source" for the page that is rendered, this is what appears:

    &lt;ul&gt;
        &lt;li&gt;one&lt;/li&gt;
        &lt;li&gt;two&lt;/li&gt;
        &lt;li&gt;three&lt;/li&gt;
    &lt;/ul&gt;
    

    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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜