module Haml::Precompiler
def self.build_attributes(is_html, attr_wrapper, attributes = {})
def self.build_attributes(is_html, attr_wrapper, attributes = {}) quote_escape = attr_wrapper == '"' ? """ : "'" other_quote_char = attr_wrapper == '"' ? "'" : '"' result = attributes.collect do |attr, value| next if value.nil? if value == true next " #{attr}" if is_html next " #{attr}=#{attr_wrapper}#{attr}#{attr_wrapper}" elsif value == false next end value = Haml::Helpers.preserve(Haml::Helpers.escape_once(value.to_s)) # We want to decide whether or not to escape quotes value.gsub!('"', '"') this_attr_wrapper = attr_wrapper if value.include? attr_wrapper if value.include? other_quote_char value = value.gsub(attr_wrapper, quote_escape) else this_attr_wrapper = other_quote_char end end " #{attr}=#{this_attr_wrapper}#{value}#{this_attr_wrapper}" end result.compact.sort.join end