123456789_123456789_123456789_123456789_123456789_

Class: Nokogiri::HTML4::Builder

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
Instance Chain:
Inherits: Nokogiri::XML::Builder
Defined in: lib/nokogiri/html4/builder.rb

Overview

::Nokogiri HTML builder is used for building ::Nokogiri::HTML documents. It is very similar to the ::Nokogiri::XML::Builder. In fact, you should go read the documentation for ::Nokogiri::XML::Builder before reading this documentation.

Synopsis:

Create an ::Nokogiri::HTML document with a body that has an onload attribute, and a span tag with a class of “bold” that has content of “Hello world”.

builder = Nokogiri::HTML4::Builder.new do |doc|
  doc.html {
    doc.body(:onload => 'some_func();') {
      doc.span.bold {
        doc.text "Hello world"
      }
    }
  }
end
puts builder.to_html

The HTML builder inherits from the ::Nokogiri::XML builder, so make sure to read the ::Nokogiri::XML::Builder documentation.

Constant Summary

::Nokogiri::ClassResolver - Included

VALID_NAMESPACES

::Nokogiri::XML::Builder - Inherited

DEFAULT_DOCUMENT_OPTIONS

Class Method Summary

::Nokogiri::XML::Builder - Inherited

.new

Create a new Builder object.

.with

Create a builder with an existing root object.

Instance Attribute Summary

::Nokogiri::XML::Builder - Inherited

#context

A context object for use when the block has no arguments.

#doc

The current Document object being built.

#parent

The parent of the current node being built.

#arity

Instance Method Summary

::Nokogiri::XML::Builder - Inherited

#<<

Append the given raw ::Nokogiri::XML string to the document.

#[]

Build a tag that is associated with namespace ns.

#cdata

Create a CDATA Node with content of string

#comment

Create a Comment Node with content of string

#text

Create a Text Node with content of string

#to_xml

Convert this Builder object to ::Nokogiri::XML.

#insert

Insert node as a child of the current Node.

#method_missing

::Nokogiri::ClassResolver - Included

#related_class

Find a class constant within the.

Constructor Details

This class inherits a constructor from Nokogiri::XML::Builder

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Nokogiri::XML::Builder

Instance Method Details

#to_html

Convert the builder to ::Nokogiri::HTML

[ GitHub ]

  
# File 'lib/nokogiri/html4/builder.rb', line 32

def to_html
  @doc.to_html
end