class HamlLint::Tree::ScriptNode

Represents a node which produces output based on Ruby code.

Public Instance Methods

parsed_script() click to toggle source

The Ruby script contents parsed into a syntax tree.

@return [ParsedRuby] syntax tree in the form returned by Parser gem

# File lib/haml_lint/tree/script_node.rb, line 11
def parsed_script
  statement =
    if children.empty?
      script
    else
      "#{script}#{@value[:keyword] == 'case' ? ';when 0;end' : ';end'}"
    end
  HamlLint::ParsedRuby.new(HamlLint::RubyParser.new.parse(statement))
end
script() click to toggle source

Returns the source for the script following the ‘-` marker.

@return [String]

# File lib/haml_lint/tree/script_node.rb, line 24
def script
  @value[:text]
end