Class: HtmlToHaml::NonHtmlSelectorBlocks::BasicConversionUseCase
- Inherits:
-
Object
- Object
- HtmlToHaml::NonHtmlSelectorBlocks::BasicConversionUseCase
- Includes:
- HamlWhitespaceCleaner, TagTypeMatchers
- Defined in:
- lib/html_to_haml/use_cases/non_html_selector_blocks/basic_conversion_use_case.rb
Direct Known Subclasses
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
- #convert ⇒ Object
-
#initialize(special_html) ⇒ BasicConversionUseCase
constructor
A new instance of BasicConversionUseCase.
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
#convert ⇒ Object
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 |