class Hpricot::Elem

@private
@see Hpricot

def dynamic_attribute?(name, options)

def dynamic_attribute?(name, options)
  options[:rhtml] and dynamic_attributes.key?(name)
end

def dynamic_attributes

def dynamic_attributes
  @dynamic_attributes ||= begin
    Haml::Util.map_hash(attr_hash) do |name, value|
      next if value.empty?
      full_match = nil
      ruby_value = value.gsub(%r{<haml:loud>\s*(.+?)\s*</haml:loud>}) do
        full_match = $`.empty? && $'.empty?
        CGI.unescapeHTML(full_match ? $1: "\#{#{$1}}")
      end
      next if ruby_value == value
      [name, full_match ? ruby_value : %("#{ruby_value}")]
    end
  end
end

def haml_attributes(options)

that's prettier than that produced by Hash#inspect
Returns a string representation of an attributes hash
def haml_attributes(options)
  attrs = attr_hash.map do |name, value|
    value = dynamic_attribute?(name, options) ? dynamic_attributes[name] : value.inspect
    name = name.index(/\W/) ? name.inspect : ":#{name}"
    "#{name} => #{value}"
  end
  "{ #{attrs.join(', ')} }"
end

def haml_tag_loud(text)

def haml_tag_loud(text)
  "= #{text.gsub(/\n\s*/, ' ').strip}\n"
end

def haml_tag_silent(text)

def haml_tag_silent(text)
  text.split("\n").map { |line| "- #{line.strip}\n" }.join
end

def static_attribute?(name, options)

def static_attribute?(name, options)
  attr_hash[name] and !dynamic_attribute?(name, options)
end

def static_classname?(options)

def static_classname?(options)
  static_attribute?('class', options)
end

def static_id?(options)

def static_id?(options)
  static_attribute?('id', options)
end

def to_haml(tabs, options)

Other tags:
    See: Haml::HTML::Node#to_haml -
def to_haml(tabs, options)
  output = "#{tabulate(tabs)}"
  if options[:rhtml] && name[0...5] == 'haml:'
    return output + send("haml_tag_#{name[5..-1]}", CGI.unescapeHTML(self.inner_text))
  end
  output += "%#{name}" unless name == 'div' &&
    (static_id?(options) || static_classname?(options))
  if attr_hash
    if static_id?(options)
      output += "##{attr_hash['id']}"
      remove_attribute('id')
    end
    if static_classname?(options)
      attr_hash['class'].split(' ').each { |c| output += ".#{c}" }
      remove_attribute('class')
    end
    output += haml_attributes(options) if attr_hash.length > 0
  end
  (self.children || []).inject(output + "\n") do |output, child|
    output + child.to_haml(tabs + 1, options)
  end
end