Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
15 lines (11 sloc) 475 Bytes
Rails helper to XHTML-ize chunks of user submitted HTML. For the standardista in all of us.
>> html = "<div><p>foo</p><a href=''>foo"
=> "<div><p>foo</p><a href=''>foo"
>> xhtmlize(html)
=> "<div><p>foo</p><a href=\"\">foo</a></div>"
Also comes with an ActiveRecord class method to automatically xhtmlize attributes in an after_save callback.
class Comment < ActiveRecord::Base
xhtmlize :title, :content
Jump to Line
Something went wrong with that request. Please try again.