【问题标题】:best_in_place and html_safebest_in_place 和 html_safe
【发布时间】: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


    【解决方案1】:

    你可以试试这个功能更多的宝石,可能会解决你的问题

    gem 'htmlentities'
    gem 'RedCloth'
    

    在此处查找 gem 文档

    Ruby gems

    【讨论】:

    • 试试吧,因为我已经在我的应用程序中使用了它们,你可以在 github 上查看更多信息。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-03-30
    • 2012-03-23
    • 1970-01-01
    • 2012-04-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多