class Nokogiri::HTML4::Builder
Nokogiri HTML builder is used for building 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 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 XML builder, so make sure to read the Nokogiri::XML::Builder documentation.
Public Instance Methods
# File lib/nokogiri/html4/builder.rb, line 32 def to_html @doc.to_html end
Convert the builder to HTML
© 2008–2023 by Mike Dalessio, Aaron Patterson, Yoko Harada, Akinori MUSHA, John Shahid,
Karol Bucek, Sam Ruby, Craig Barnes, Stephen Checkoway, Lars Kanis, Sergio Arbeo,
Timothy Elliott, Nobuyoshi Nakada, Charles Nutter, Patrick MahoneyLicensed under the MIT License.
https://nokogiri.org/rdoc/Nokogiri/HTML4/Builder.html