Module: Loofah::HtmlFragmentBehavior::ClassMethods
- Defined in:
- lib/loofah/concerns.rb
Instance Method Summary collapse
Instance Method Details
#document_klass ⇒ Object
180 181 182 183 184 185 186 187 188 |
# File 'lib/loofah/concerns.rb', line 180 def document_klass @document_klass ||= if Loofah.html5_support? && self == Loofah::HTML5::DocumentFragment Loofah::HTML5::Document elsif self == Loofah::HTML4::DocumentFragment Loofah::HTML4::Document else raise ArgumentError, "unexpected class: #{self}" end end |
#parse(tags, encoding = nil) ⇒ Object
171 172 173 174 175 176 177 178 |
# File 'lib/loofah/concerns.rb', line 171 def parse(, encoding = nil) doc = document_klass.new encoding ||= .respond_to?(:encoding) ? .encoding.name : "UTF-8" doc.encoding = encoding new(doc, ) end |