Class: SyntaxTree::ERB::HtmlNode::OpeningTag
- Defined in:
- lib/syntax_tree/erb/nodes.rb
Overview
The opening tag of an element. It contains the opening character (<), the name of the element, any optional attributes, and the closing token (either > or />).
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#closing ⇒ Object
readonly
Returns the value of attribute closing.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#opening ⇒ Object
readonly
Returns the value of attribute opening.
Attributes inherited from Element
Instance Method Summary collapse
- #accept(visitor) ⇒ Object
- #child_nodes ⇒ Object (also: #deconstruct)
- #deconstruct_keys(keys) ⇒ Object
-
#initialize(opening:, name:, attributes:, closing:, new_line:, location:) ⇒ OpeningTag
constructor
A new instance of OpeningTag.
- #is_void_element? ⇒ Boolean
Methods inherited from Element
Methods inherited from Node
#format, #pretty_print, #skip?, #without_new_line
Constructor Details
#initialize(opening:, name:, attributes:, closing:, new_line:, location:) ⇒ OpeningTag
Returns a new instance of OpeningTag.
171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
# File 'lib/syntax_tree/erb/nodes.rb', line 171 def initialize( opening:, name:, attributes:, closing:, new_line:, location: ) super(new_line: new_line, location: location) @opening = opening @name = name @attributes = attributes @closing = closing end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
169 170 171 |
# File 'lib/syntax_tree/erb/nodes.rb', line 169 def attributes @attributes end |
#closing ⇒ Object (readonly)
Returns the value of attribute closing.
169 170 171 |
# File 'lib/syntax_tree/erb/nodes.rb', line 169 def closing @closing end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
169 170 171 |
# File 'lib/syntax_tree/erb/nodes.rb', line 169 def name @name end |
#opening ⇒ Object (readonly)
Returns the value of attribute opening.
169 170 171 |
# File 'lib/syntax_tree/erb/nodes.rb', line 169 def opening @opening end |
Instance Method Details
#accept(visitor) ⇒ Object
186 187 188 |
# File 'lib/syntax_tree/erb/nodes.rb', line 186 def accept(visitor) visitor.visit_opening_tag(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
190 191 192 |
# File 'lib/syntax_tree/erb/nodes.rb', line 190 def child_nodes [opening, name, *attributes, closing] end |
#deconstruct_keys(keys) ⇒ Object
200 201 202 203 204 205 206 207 |
# File 'lib/syntax_tree/erb/nodes.rb', line 200 def deconstruct_keys(keys) super.merge( opening: opening, name: name, attributes: attributes, closing: closing ) end |
#is_void_element? ⇒ Boolean
194 195 196 |
# File 'lib/syntax_tree/erb/nodes.rb', line 194 def is_void_element? HTML_VOID_ELEMENTS.include?(name.value) end |