Class: SyntaxTree::ERB::ErbContent
- Defined in:
- lib/syntax_tree/erb/nodes.rb
Instance Attribute Summary collapse
-
#unparsed_value ⇒ Object
readonly
Returns the value of attribute unparsed_value.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #accept(visitor) ⇒ Object
- #child_nodes ⇒ Object (also: #deconstruct)
- #deconstruct_keys(keys) ⇒ Object
-
#initialize(value:) ⇒ ErbContent
constructor
A new instance of ErbContent.
Methods inherited from Node
Constructor Details
#initialize(value:) ⇒ ErbContent
Returns a new instance of ErbContent.
362 363 364 365 366 367 368 369 370 |
# File 'lib/syntax_tree/erb/nodes.rb', line 362 def initialize(value:) @unparsed_value = value begin @value = SyntaxTree.parse(value.strip) rescue SyntaxTree::Parser::ParseError # Removes leading and trailing whitespace @value = value&.lstrip&.rstrip end end |
Instance Attribute Details
#unparsed_value ⇒ Object (readonly)
Returns the value of attribute unparsed_value.
360 361 362 |
# File 'lib/syntax_tree/erb/nodes.rb', line 360 def unparsed_value @unparsed_value end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
360 361 362 |
# File 'lib/syntax_tree/erb/nodes.rb', line 360 def value @value end |
Instance Method Details
#accept(visitor) ⇒ Object
372 373 374 |
# File 'lib/syntax_tree/erb/nodes.rb', line 372 def accept(visitor) visitor.visit_erb_content(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
376 377 378 |
# File 'lib/syntax_tree/erb/nodes.rb', line 376 def child_nodes [] end |
#deconstruct_keys(keys) ⇒ Object
382 383 384 |
# File 'lib/syntax_tree/erb/nodes.rb', line 382 def deconstruct_keys(keys) { value: value } end |