class Arbre::HTML::Element

def self.builder_method(method_name)

def self.builder_method(method_name)
  ::Arbre::Builder::BuilderMethods.class_eval <<-EOF, __FILE__, __LINE__
    def #{method_name}(*args, &block)
      insert_tag ::#{self.name}, *args, &block
    end
  EOF
end

def +(element)

def +(element)
  case element
  when Element, Collection
  else
    element = Arbre::HTML::TextNode.from_string(element)
  end
  Collection.new([self]) + element
end

def <<(child)

def <<(child)
  add_child(child)
end

def add_child(child)

def add_child(child)
  return unless child
  if child.is_a?(Array)
    child.each{|item| add_child(item) }
    return @children
  end
  # If its not an element, wrap it in a TextNode
  unless child.is_a?(Element)
    child = Arbre::HTML::TextNode.from_string(child)
  end
  if child.respond_to?(:parent)
    # Remove the child
    child.parent.remove_child(child) if child.parent
    # Set ourselves as the parent
    child.parent = self
  end
  @children << child
end

def assigns

def assigns
  @_assigns
end

def build(*args, &block)

def build(*args, &block)
  # Render the block passing ourselves in
  insert_text_node_if_string(block.call(self)) if block
end

def clear_children!

Resets the Elements children
def clear_children!
  @children.clear
end

def content

def content
  children.to_html
end

def content=(contents)

def content=(contents)
  clear_children!
  add_child(contents)
end

def document

def document
  parent.document if parent?
end

def each(&block)

def each(&block)
  [to_html].each(&block)
end

def get_elements_by_tag_name(tag_name)

def get_elements_by_tag_name(tag_name)
  elements = Collection.new
  children.each do |child|
    elements << child if child.tag_name == tag_name
    elements.concat(child.get_elements_by_tag_name(tag_name))
  end
  elements
end

def helpers

def helpers
  @_helpers
end

def html_safe

def html_safe
  to_html
end

def indent_level

def indent_level
  parent? ? parent.indent_level + 1 : 0
end

def initialize(assigns = {}, helpers = nil)

def initialize(assigns = {}, helpers = nil)
  @_assigns, @_helpers = assigns, helpers
  @children = Collection.new
end

def parent=(parent)

def parent=(parent)
  @parent = parent
end

def parent?

def parent?
  !@parent.nil?
end

def remove_child(child)

def remove_child(child)
  child.parent = nil if child.respond_to?(:parent=)
  @children.delete(child)
end

def tag_name

def tag_name
  @tag_name ||= self.class.name.demodulize.downcase
end

def to_ary

def to_ary
  Collection.new [self]
end

def to_html

def to_html
  content
end

def to_s

def to_s
  to_html
end

def to_str

def to_str
  to_s
end