Class: SyntaxTree::Haml::Format::Formatter

Inherits:
Formatter
  • Object
show all
Defined in:
lib/syntax_tree/haml/format.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source, *rest, options: ::SyntaxTree::Formatter::Options.new) ⇒ Formatter

Returns a new instance of Formatter.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/syntax_tree/haml/format.rb', line 9

def initialize(
  source,
  *rest,
  options: ::SyntaxTree::Formatter::Options.new
)
  @literal_lines = {}
  source
    .lines
    .each
    .with_index(1) do |line, index|
      @literal_lines[index] = line.rstrip if line.start_with?("!")
    end

  super(source, *rest, options: options)
end

Instance Attribute Details

#literal_linesObject (readonly)

Returns the value of attribute literal_lines.



7
8
9
# File 'lib/syntax_tree/haml/format.rb', line 7

def literal_lines
  @literal_lines
end