best_in_place和html_safe [英] best_in_place and html_safe
问题描述
我正在Rails应用程序中使用 best_in_place gem 进行内联编辑.我在尝试呈现一些文本HTML安全性时遇到问题.
I'm using the best_in_place gem in my rails app to allow for inline editing. I'm running into issues with trying to render some text html safe.
未指定文本应为html_safe,这就是页面上的样子:
Without specifying that the text should be made html_safe, this is what it looks like on the page:
我查看了best_in_place文档,并尝试添加以下行以使html文本安全:
I looked at the best_in_place documentation and tried adding the following lines to render the text html safe:
<div id="projectOverviewDescription">
<p>
<%= best_in_place @project.overview, :description,
:path => project_step_path(@project, @project.overview),
:type => :textarea,
:nil=> "Add a description of your project here!",
:display_with => lambda { |v| v.html_safe } %>
</p>
</div>
但是最终结果如下:
看起来文本忽略了我的CSS溢出规则,并且best_in_place编辑使用nil占位符(添加描述...")(当已有描述时). 使用best_in_place生成html_safe文本的最佳方法是什么?
It looks like the text ignores my css overflow rules and also, the best_in_place editing uses the nil placeholder ("add a description...") when there is a description already. What's the best way to produce html_safe text using best_in_place?
这是我的CSS:
#projectOverviewDescription{
position: absolute;
top: 0;
right: 0;
width: 250px;
padding: 20px;
float: right;
height: 236px;
border-top-right-radius: 7px;
border-bottom-right-radius: 7px;
background: $titlegrey;
opacity: 0.7;
p{
color: white;
height: 236px;
overflow-y: scroll;
overflow-x: hidden;
}
}
推荐答案
您可以尝试一下具有更多功能并且可以解决您的问题的宝石
You can try this gems that have more functionalities and may solve your problems
gem 'htmlentities'
gem 'RedCloth'
在此处查找宝石文档
这篇关于best_in_place和html_safe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!