Class: HtmlToHaml::NonHtmlSelectorBlocks::BasicConversionUseCase

Inherits:
Object
  • Object
show all
Includes:
HamlWhitespaceCleaner, TagTypeMatchers
Defined in:
lib/html_to_haml/use_cases/non_html_selector_blocks/basic_conversion_use_case.rb

Constant Summary collapse

RUBY_HAML_REGEX =
"\n\s*=.*\n"

Constants included from TagTypeMatchers

TagTypeMatchers::TAG_TYPE_FROM_REGEX, TagTypeMatchers::TAG_TYPE_REGEX

Instance Method Summary collapse

Constructor Details

#initialize(special_html) ⇒ BasicConversionUseCase



14
15
16
# File 'lib/html_to_haml/use_cases/non_html_selector_blocks/basic_conversion_use_case.rb', line 14

def initialize(special_html)
  @special_html = special_html
end

Instance Method Details

#convertObject



18
19
20
21
22
23
24
# File 'lib/html_to_haml/use_cases/non_html_selector_blocks/basic_conversion_use_case.rb', line 18

def convert
  indentation_tracker = IndentationTracker.new(indented: false, adjust_whitespace: false)
  haml = @special_html.gsub(/#{opening_tag_regex}|#{closing_tag_regex}|#{RUBY_HAML_REGEX}|(\n\s*)/) do |tag|
    replace_tag_value(tag: tag, indentation_tracker: indentation_tracker)
  end
  remove_haml_whitespace(haml: haml)
end