2

通常,ActionText 会去除未明确列入白名单的任何标签或 html 属性(有些是默认设置)。例如,当前任何样式属性都被剥离。

要允许自定义属性或标签,请添加一个初始化程序,例如config/initializers/action_text.rb

# white list the attribute style for action text. e.g. <tag_name style="">
ActionText::Attachment::ATTRIBUTES << "style"

# allow additional tags in custom attachments. 
ActionText::ContentHelper.allowed_tags += ['table', 'tr', 'td']
4

0 回答 0