Module: Mato::Concerns::HtmlNodeCheckable

Included in:
HtmlFilters::MentionLink, HtmlFilters::TokenLink
Defined in:
lib/mato/concerns/html_node_checkable.rb

Class Method Summary collapse

Class Method Details

.has_ancestor?(node, *tags) ⇒ Boolean

Returns true if the node has the specified tags as a parent.

Parameters:

  • node (Nokogiri::XML::Node)
  • tags (Array<String>)
    • set of tags

Returns:

  • (Boolean)

    true if the node has the specified tags as a parent



11
12
13
14
15
16
17
18
19
# File 'lib/mato/concerns/html_node_checkable.rb', line 11

def has_ancestor?(node, *tags)
  current = node
  while (current = current.parent)
    if tags.include?(current.name)
      return true
    end
  end
  false
end