Class: HtmlToHaml::Erb::IndentationConversionUseCase

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Singleton
Defined in:
lib/html_to_haml/use_cases/erb/indentation_conversion_use_case.rb

Constant Summary collapse

SNARKY_COMMENT_FOR_HAVING_NESTED_CASE_STATEMENTS =
"/ It looks like this is the start of a nested case statement\n/ Are you REALLY sure you want or need one? Really?\n/ This converter will convert it for you below, but you should\n/ seriously rethink your code right now.\n"

Instance Method Summary collapse

Instance Method Details

#convert_indentation(erb:) ⇒ Object



19
20
21
22
23
24
25
26
# File 'lib/html_to_haml/use_cases/erb/indentation_conversion_use_case.rb', line 19

def convert_indentation(erb:)
  indentation_converter = new_indentation_converter
  erb.split("\n").map do |erb_line|
    indentation = indentation_for_line_or_error(erb: erb_line, indentation_level: indentation_converter.indentation_level)
    adjust_indentation_level(erb: erb_line, indentation_converter: indentation_converter)
    construct_haml_line(erb: erb_line, indentation: indentation, indentation_converter: indentation_converter)
  end.join
end