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