Class: Dommy::XMLSerializer
- Inherits:
-
Object
- Object
- Dommy::XMLSerializer
- Includes:
- Bridge::Methods
- Defined in:
- lib/dommy/dom_parser.rb
Overview
XMLSerializer — round-trip a node tree to a string. Used for
XML output, SVG inlining, and "serialize this Element" patterns.
For HTML, prefer Element#outer_html directly.
Instance Method Summary collapse
- #__js_call__(method, args) ⇒ Object
- #__js_get__(_key) ⇒ Object
-
#serialize_to_string(node) ⇒ Object
(also: #serializeToString)
WHATWG "XML serialization" — produce XML (self-closing empty tags, real XML escaping) rather than the HTML serialization
outer_htmlgives.
Methods included from Bridge::Methods
Instance Method Details
#__js_call__(method, args) ⇒ Object
85 86 87 88 89 90 |
# File 'lib/dommy/dom_parser.rb', line 85 def __js_call__(method, args) case method when "serializeToString" serialize_to_string(args[0]) end end |
#__js_get__(_key) ⇒ Object
79 80 81 |
# File 'lib/dommy/dom_parser.rb', line 79 def __js_get__(_key) Bridge::ABSENT # method-only; any property read is absent end |
#serialize_to_string(node) ⇒ Object Also known as: serializeToString
WHATWG "XML serialization" — produce XML (self-closing empty tags, real XML
escaping) rather than the HTML serialization outer_html gives. Delegates
to the backend's XML serializer (Nokogiri); namespace handling is whatever
the backend produces. A Document serializes its root element.
71 72 73 74 75 |
# File 'lib/dommy/dom_parser.rb', line 71 def serialize_to_string(node) return "" unless node Internal::XmlSerialization.serialize(node) end |