【问题标题】:Action Text displaying html tags显示 html 标记的操作文本
【发布时间】:2021-05-01 02:55:21
【问题描述】:

我使用 Action Text 来创建文章并很好地显示文章的内容。 但是我有一个问题,当我创建我的文章然后显示它显示 HTML 标签的内容时。 这里 :

这是我的代码:

articles/show.html.erb :

<%= @article.body %>

application.scss:

@import "trix/dist/trix";
@import "./actiontext.scss";

_form.html.erb:

<%= form_for @article do |f| %>
<%= f.rich_text_area :body, height: "300px", width:"300px" %>
<%= end %>

application.js:

//= require actiontext
require("trix")
require("@rails/actiontext")

actiontext.scss:

.trix-content {
  .attachment-gallery {
    > action-text-attachment,
    > .attachment {
      flex: 1 0 33%;
      padding: 0 0.5em;
      max-width: 33%;
    }

    &.attachment-gallery--2,
    &.attachment-gallery--4 {
      > action-text-attachment,
      > .attachment {
        flex-basis: 50%;
        max-width: 50%;
      }
    }
  }

  action-text-attachment {
    .attachment {
      padding: 0 !important;
      max-width: 100% !important;
    }
  }
}

有人知道吗?

【问题讨论】:

    标签: ruby-on-rails actiontext


    【解决方案1】:

    我不知道为什么操作文本会显示 HTML 应答器,但也许使用 SanitizeHelper 会帮助您移除应答器。

    在遇到类似问题后,我们在项目中使用它。

    【讨论】:

    • 非常感谢,它成功了,我刚刚添加了
    猜你喜欢
    • 1970-01-01
    • 2019-12-06
    • 1970-01-01
    • 1970-01-01
    • 2018-10-30
    • 1970-01-01
    • 2016-10-29
    • 1970-01-01
    • 2016-04-01
    相关资源
    最近更新 更多