class Sablon::HTMLConverter::Root

Stores all of the AST nodes from the current fragment of HTML being parsed

Public Class Methods

new(env, node) click to toggle source
Calls superclass method Sablon::HTMLConverter::Collection::new
# File lib/sablon/html/ast.rb, line 131
def initialize(env, node)
  # strip text nodes from the root level element, these are typically
  # extra whitespace from indenting the markup if there are any
  # block level tags at the top level
  if ASTBuilder.any_block_tags?(node.children)
    node.search('./text()').remove
  end

  # convert children from HTML to AST nodes
  super(ASTBuilder.html_to_ast(env, node.children, {}))
end

Public Instance Methods

grep(pattern) click to toggle source
# File lib/sablon/html/ast.rb, line 143
def grep(pattern)
  visitor = GrepVisitor.new(pattern)
  accept(visitor)
  visitor.result
end
inspect() click to toggle source
# File lib/sablon/html/ast.rb, line 149
def inspect
  "<Root: #{super}>"
end