1
我在我的rails应用程序中使用best_in_place gem以允许进行内联编辑。我遇到了试图呈现一些文本HTML安全问题。best_in_place和html_safe
不指定文本应该进行html_safe,这是它看起来像在页面上:
我看着best_in_place文件和尝试添加以下行来渲染文本的HTML安全:
<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文本的最佳方式是什么?
这里是我的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;
}
}
尝试它会工作,因为我已经在我的应用程序中使用它们您可以在github上查看更多信息。 –
我会试试这个,谢谢! – scientiffic