module HtmlToHaml::NonHtmlSelectorBlocks::TagTypeMatchers

Constants

TAG_TYPE_FROM_REGEX
TAG_TYPE_REGEX

Private Instance Methods

closing_tag?(tag:, in_block:) click to toggle source
# File lib/html_to_haml/tools/non_html_selector_blocks/tag_type_matchers.rb, line 17
def closing_tag?(tag:, in_block:)
  in_block && tag =~ /#{closing_tag_regex}/
end
closing_tag_regex() click to toggle source
# File lib/html_to_haml/tools/non_html_selector_blocks/tag_type_matchers.rb, line 21
def closing_tag_regex
  "<\/#{self.class::HTML_TAG_NAME}>"
end
opening_tag?(tag:, in_block:) click to toggle source
# File lib/html_to_haml/tools/non_html_selector_blocks/tag_type_matchers.rb, line 9
def opening_tag?(tag:, in_block:)
  !in_block && tag =~ /#{opening_tag_regex}/
end
opening_tag_regex() click to toggle source
# File lib/html_to_haml/tools/non_html_selector_blocks/tag_type_matchers.rb, line 13
def opening_tag_regex
  "<#{self.class::HTML_TAG_NAME}.*?>"
end
specified_tag_type(tag:) click to toggle source
# File lib/html_to_haml/tools/non_html_selector_blocks/tag_type_matchers.rb, line 29
def specified_tag_type(tag:)
  type_match = tag.match(/#{self.class::TAG_TYPE_REGEX}/)
  type_match && type_match.to_s.gsub(/#{self.class::TAG_TYPE_REGEX}/, self.class::TAG_TYPE_FROM_REGEX).split('/').last
end
tag_type(tag:) click to toggle source
# File lib/html_to_haml/tools/non_html_selector_blocks/tag_type_matchers.rb, line 25
def tag_type(tag:)
  specified_tag_type(tag: tag) || self.class::DEFAULT_TAG_TYPE
end