class Hpricot::Elem

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