我用rails创建了一个博客。我是一个初学者,走得很远,但现在我被一个看似次要的细节所困:我似乎不能格式化帖子(文章)。
下面是我的show.html.erb的相关部分:
<p>
<strong>Content:</strong>
<%= simple_format (@article.content) %>
</p>当我写一些东西并插入html标签时,它们不会被识别出来。我做错了什么?
发布于 2015-12-19 02:05:11
您现在可以指定包装它的标签(默认为p),如下所示:
<%= simple_format (@article.content, {}, wrapper_tag: "div") %>或
添加white-space: pre-line样式。
它将在用户输入中显示\r或\n (enter)作为新行。
有关更多信息,请访问:http://apidock.com/rails/v4.0.2/ActionView/Helpers/TextHelper/simple_format
https://stackoverflow.com/questions/34361283
复制相似问题