ActionText: Custom Attachment with table support & whitelisting attributes (like style)

557 Views Asked by At

Typically ActionText will strip any tags or html attributes, which are not explicitly whitelisted (some are by default). For example, any style attribute currently is stripped.

To allow the custom attributes or tags, add an initializer, e.g 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']
0

There are 0 best solutions below