Module: Ronin::Web::HTML

Defined in:
lib/ronin/web/html.rb

Overview

HTML helper methods.

Since:

  • 1.0.0

Class Method Summary collapse

Class Method Details

.build { ... } ⇒ Nokogiri::HTML::Builder

Creates a new Nokogiri::HTML::Builder.

Examples:

HTML.build do
  html {
    body {
      div(style: 'display:none;') {
        object(classid: 'blabla')
      }
    }
  }
end

Yields:

  • [] The block that will be used to construct the HTML document.

Returns:

  • (Nokogiri::HTML::Builder)

    The new HTML builder object.

See Also:

Since:

  • 1.0.0



81
82
83
# File 'lib/ronin/web/html.rb', line 81

def self.build(&block)
  Nokogiri::HTML::Builder.new(&block)
end

.parse(html) {|doc| ... } ⇒ Nokogiri::HTML::Document

Parses the body of a document into a HTML document object.

Parameters:

  • html (String, IO)

    The HTML to parse.

Yields:

  • (doc)

    If a block is given, it will be passed the newly created document object.

Yield Parameters:

  • doc (Nokogiri::HTML::Document)

    The new HTML document object.

Returns:

  • (Nokogiri::HTML::Document)

    The new HTML document object.

See Also:

Since:

  • 1.0.0



51
52
53
54
55
# File 'lib/ronin/web/html.rb', line 51

def self.parse(html)
  doc = Nokogiri::HTML.parse(html)
  yield doc if block_given?
  return doc
end