ruby-on-rails - 显示 html 标记的操作文本
问题描述
我正在使用 Action Text 来创建文章并很好地显示它的内容。但是我有一个问题,当我创建我的文章然后显示它显示 HTML 标记的内容时。这里 :
这是我的代码:
文章/show.html.erb :
<%= @article.body %>
应用程序.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 %>
应用程序.js:
//= require actiontext
require("trix")
require("@rails/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;
}
}
}
有人知道吗?
解决方案
好吧,我不知道为什么操作文本会显示 HTML 应答器,但也许使用SanitizeHelper可以帮助您删除应答器。
在遇到类似问题后,我们在项目中使用它。
推荐阅读
- regex - 分组中的 SCALA 字数
- python - 错误:将检查点与图合并以获得冻结图
- r - 回复:错误!!: 'S4' 类型的对象不是子集
- html - 将 div 居中并为一侧的空间赋予颜色
- react-native-navigation - React Native Navigation:设置flex值时抽屉项目不显示或消失
- neural-network - 使用遗传算法训练井字游戏的神经网络
- node.js - Npm 安装错误,请求 http://registry.npmjs.org/concurrently 的愚蠢 fetchpackagemetadata 错误,原因:套接字挂起
- android - 在约束布局中垂直对齐按钮
- c++ - 使用 OpenVDB 重构 Enright 测试
- python - Selenium:启动 Firefox 并启用扩展