Class: SyntaxTree::ERB::HtmlNode
- Defined in:
- lib/syntax_tree/erb/nodes.rb
Overview
An element is a child of the document. It contains an opening tag, any optional content within the tag, and a closing tag. It can also potentially contain an opening tag that self-closes, in which case the content and closing tag will be nil.
Defined Under Namespace
Classes: ClosingTag, OpeningTag
Constant Summary collapse
- HTML_VOID_ELEMENTS =
These elements do not require a closing tag developer.mozilla.org/en-US/docs/Glossary/Void_element
%w[ area base br col embed hr img input link meta param source track wbr ]
Instance Attribute Summary
Attributes inherited from Block
#closing, #elements, #location, #opening
Instance Method Summary collapse
- #accept(visitor) ⇒ Object
- #is_void_element? ⇒ Boolean
-
#new_line ⇒ Object
The HTML-closing tag is responsible for new lines after the node.
- #without_new_line ⇒ Object
Methods inherited from Block
#child_nodes, #deconstruct_keys, #initialize
Methods inherited from Node
#format, #pretty_print, #skip?
Constructor Details
This class inherits a constructor from SyntaxTree::ERB::Block
Instance Method Details
#accept(visitor) ⇒ Object
255 256 257 |
# File 'lib/syntax_tree/erb/nodes.rb', line 255 def accept(visitor) visitor.visit_html(self) end |
#is_void_element? ⇒ Boolean
237 238 239 |
# File 'lib/syntax_tree/erb/nodes.rb', line 237 def is_void_element? false end |
#new_line ⇒ Object
The HTML-closing tag is responsible for new lines after the node.
251 252 253 |
# File 'lib/syntax_tree/erb/nodes.rb', line 251 def new_line closing.nil? ? opening.new_line : closing&.new_line end |
#without_new_line ⇒ Object
241 242 243 244 245 246 247 248 |
# File 'lib/syntax_tree/erb/nodes.rb', line 241 def without_new_line self.class.new( **deconstruct_keys([]).merge( opening: closing.nil? ? opening.without_new_line : opening, closing: closing&.without_new_line ) ) end |