Class: HamlLint::Tree::FilterNode

Inherits:
Node
  • Object
show all
Defined in:
lib/haml_lint/tree/filter_node.rb

Overview

Represents a filter node which contains arbitrary code.

Instance Attribute Summary

Attributes inherited from Node

#children, #line, #parent, #type

Instance Method Summary collapse

Methods inherited from Node

#comment_configuration, #directives, #disabled?, #each, #initialize, #inspect, #keyword, #line_numbers, #lines, #next_node, #predecessor, #source_code, #subsequents, #successor

Constructor Details

This class inherits a constructor from HamlLint::Tree::Node

Instance Method Details

#filter_typeObject

The type of code contained in this filter.



7
8
9
# File 'lib/haml_lint/tree/filter_node.rb', line 7

def filter_type
  @value[:name]
end

#textObject



11
12
13
14
15
16
17
18
19
# File 'lib/haml_lint/tree/filter_node.rb', line 11

def text
  # Seems HAML strips the starting blank lines... without them, line numbers become offset,
  # breaking the source_map and auto-correct

  nb_blank_lines = 0
  nb_blank_lines += 1 while @document.source_lines[line + nb_blank_lines]&.empty?

  "#{"\n" * nb_blank_lines}#{super}"
end