看完 这个 RailsCast 后,我想我应该给 RedCloth 尝试一下。不幸的是,我似乎遇到了一个问题,涉及对生成的 HTML 进行编码而不是呈现为直接 HTML。
-
首先,我将以下内容添加到我的 Gemfile 中:
宝石“红布”,“4.2.7”
-
我在视图中添加了基本的 RedCloth 实现:
<%= RedCloth.new("* 一\n* 二\n * 三").to_html %>
-
当我“查看渲染页面的源代码”时,将出现以下内容:
我期望的输出如下:
<前><代码>
我做错了什么吗?我是否需要将参数传递给 to_html
或 RedCloth 构造函数?
After watching this RailsCast, I thought I'd give RedCloth a try. Unfortunately, it looks like 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?
发布评论
评论(1)
试试这个:
另请查看这篇博文主题。
Try this:
Also check out this blog post on the subject.