Sha256: 52c60fd2f1eb442fc0fb0ea07ec3d7840dcd426b1f0dcdd4d298be3d77fc24ce

Contents?: true

Size: 983 Bytes

Versions: 53

Compression:

Stored size: 983 Bytes

Contents

module Loofah
  module HTML # :nodoc:
    #
    #  Subclass of Nokogiri::HTML::DocumentFragment.
    #
    #  See Loofah::ScrubBehavior and Loofah::TextBehavior for additional methods.
    #
    class DocumentFragment < Nokogiri::HTML::DocumentFragment
      include Loofah::TextBehavior

      class << self
        #
        #  Overridden Nokogiri::HTML::DocumentFragment
        #  constructor. Applications should use Loofah.fragment to
        #  parse a fragment.
        #
        def parse tags, encoding = nil
          doc = Loofah::HTML::Document.new

          encoding ||= tags.respond_to?(:encoding) ? tags.encoding.name : 'UTF-8'
          doc.encoding = encoding

          new(doc, tags)
        end
      end

      #
      #  Returns the HTML markup contained by the fragment
      #
      def to_s
        serialize_root.children.to_s
      end
      alias :serialize :to_s

      def serialize_root
        at_xpath("./body") || self
      end
    end
  end
end

Version data entries

53 entries across 46 versions & 12 rubygems

Version Path
zuora_connect_ui-0.10.0 vendor/ruby/2.6.0/gems/loofah-2.3.0/lib/loofah/html/document_fragment.rb
zuora_connect_ui-0.10.0 vendor/ruby/2.6.0/gems/loofah-2.3.1/lib/loofah/html/document_fragment.rb
zuora_connect_ui-0.10.0 vendor/ruby/2.6.0/gems/loofah-2.2.3/lib/loofah/html/document_fragment.rb
zuora_connect_ui-0.9.2 vendor/ruby/2.6.0/gems/loofah-2.2.3/lib/loofah/html/document_fragment.rb
zuora_connect_ui-0.9.2 vendor/ruby/2.6.0/gems/loofah-2.3.1/lib/loofah/html/document_fragment.rb
zuora_connect_ui-0.9.2 vendor/ruby/2.6.0/gems/loofah-2.3.0/lib/loofah/html/document_fragment.rb
chatops-rpc-0.0.2 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/loofah-2.3.1/lib/loofah/html/document_fragment.rb
chatops-rpc-0.0.1 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/loofah-2.3.1/lib/loofah/html/document_fragment.rb
zuora_connect_ui-0.9.1 vendor/ruby/2.6.0/gems/loofah-2.2.3/lib/loofah/html/document_fragment.rb
zuora_connect_ui-0.9.1 vendor/ruby/2.6.0/gems/loofah-2.3.1/lib/loofah/html/document_fragment.rb
zuora_connect_ui-0.9.1 vendor/ruby/2.6.0/gems/loofah-2.3.0/lib/loofah/html/document_fragment.rb
loofah-2.3.1 lib/loofah/html/document_fragment.rb
zuora_connect_ui-0.9.0 vendor/ruby/2.6.0/gems/loofah-2.3.0/lib/loofah/html/document_fragment.rb
zuora_connect_ui-0.9.0 vendor/ruby/2.6.0/gems/loofah-2.2.3/lib/loofah/html/document_fragment.rb
loofah-2.3.0 lib/loofah/html/document_fragment.rb
zuora_connect_ui-0.8.3 vendor/ruby/2.6.0/gems/loofah-2.2.3/lib/loofah/html/document_fragment.rb
zuora_connect_ui-0.8.2 vendor/ruby/2.6.0/gems/loofah-2.2.3/lib/loofah/html/document_fragment.rb
zuora_connect_ui-0.8.1 vendor/ruby/2.6.0/gems/loofah-2.2.3/lib/loofah/html/document_fragment.rb
zuora_connect_ui-0.8.0 vendor/ruby/2.6.0/gems/loofah-2.2.3/lib/loofah/html/document_fragment.rb
spiral_form-0.1.1 vendor/bundle/gems/loofah-2.2.3/lib/loofah/html/document_fragment.rb