class DocTemplate::Tags::BlockTag

Constants

END_VALUE

Public Instance Methods

block_nodes(node) { |node| ... } click to toggle source

Collects all the nodes before the closing tag

# File lib/doc_template/tags/block_tag.rb, line 17
def block_nodes(node)
  end_tag_found = false
  tag_node = node

  # we have to collect all nodes until the we find the end tag
  nodes = [].tap do |result|
    check_tag_soft_return(node)
    while (node = node.next_sibling)
      if node.content.match?(end_tag_re)
        end_tag_found = true
        check_tag_soft_return(node)
        node.remove
        break
      end
      node = yield(node) if block_given?
      result << node
    end
  end

  no_end_tag_for(tag_node) unless end_tag_found

  nodes
end
no_end_tag_for(node) click to toggle source
# File lib/doc_template/tags/block_tag.rb, line 8
def no_end_tag_for(node)
  msg = "No tag with END value for: #{self.class::TAG_NAME.upcase}<br>" \
        "<em>#{node.parent.try(:inner_html)}</em>"
  raise DocumentError, msg
end

Private Instance Methods

end_tag_re() click to toggle source
# File lib/doc_template/tags/block_tag.rb, line 43
def end_tag_re
  @end_tag_re ||= /\[#{self.class::TAG_NAME}:\s*#{END_VALUE}\]/i
end