class Loofah::HTML::DocumentFragment

Subclass of Nokogiri::HTML::DocumentFragment.

See Loofah::ScrubBehavior and Loofah::TextBehavior for additional methods.

Public Instance Methods

serialize() click to toggle source
Alias for: to_s
serialize_root() click to toggle source
# File lib/loofah/html/document_fragment.rb, line 32
def serialize_root
  at_xpath("./body") || self
end
to_s() click to toggle source

Returns the HTML markup contained by the fragment

# File lib/loofah/html/document_fragment.rb, line 27
def to_s
  serialize_root.children.to_s
end
Also aliased as: serialize

Public Class Methods

parse(tags) click to toggle source

Overridden Nokogiri::HTML::DocumentFragment constructor. Applications should use Loofah.fragment to parse a fragment.

# File lib/loofah/html/document_fragment.rb, line 17
def parse tags
  doc = Loofah::HTML::Document.new
  doc.encoding = tags.encoding.name if tags.respond_to?(:encoding)
  self.new(doc, tags)
end