As a proof of concept here’s some console output first:
ruby-1.9.2-p180 :010 > x = "<span id='c_3'>s</span>"
=> "<span id='c_3'>s</span>"
ruby-1.9.2-p180 :011 > helper.simple_format(x)
=> "<p><span>s</span></p>"
The reason for this is that the Rails helper method simple_format call the sanitize method at the very end of it’s execution and that method strips out attributes.
I know that sanitize will allow you to specify attributes that should not be stripped. My question is: Is it possible to somehow pass the “white listed” attribute (id in this case) THROUGH simple_format ?
thanks!!
You cannot pass a white-list, but you can disable sanitization completely by doing
http://api.rubyonrails.org/classes/ActionView/Helpers/TextHelper.html#method-i-simple_format