【发布时间】:2014-01-11 07:08:07
【问题描述】:
我在我的 rails 应用程序中使用 best_in_place gem 来允许内联编辑。我在尝试使某些文本 html 安全呈现时遇到了问题。
没有指定文本应设为 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;
}
}
【问题讨论】:
标签: css ruby-on-rails overflow best-in-place html-safe