class Phlex::SGML

def __attributes__(attributes, buffer = +"")

Other tags:
    Api: - private
def __attributes__(attributes, buffer = +"")
	attributes.each do |k, v|
		next unless v
		name = case k
			when String then k
			when Symbol then k.name.tr("_", "-")
			else raise Phlex::ArgumentError.new("Attribute keys should be Strings or Symbols.")
		end
		lower_name = name.downcase
		unless Phlex::SGML::SafeObject === v
			if lower_name == "href" && v.to_s.downcase.delete("^a-z:").start_with?("javascript:")
				next
			end
			# Detect unsafe attribute names. Attribute names are considered unsafe if they match an event attribute or include unsafe characters.
			if Phlex::HTML::UNSAFE_ATTRIBUTES.include?(lower_name.delete("^a-z-"))
				raise Phlex::ArgumentError.new("Unsafe attribute name detected: #{k}.")
			end
		end
		if name.match?(/[<>&"']/)
			raise Phlex::ArgumentError.new("Unsafe attribute name detected: #{k}.")
		end
		if lower_name.to_sym == :id && k != :id
			raise Phlex::ArgumentError.new(":id attribute should only be passed as a lowercase symbol.")
		end
		case v
		when true
			buffer << " " << name
		when String
			buffer << " " << name << '="' << v.gsub('"', "&quot;") << '"'
		when Symbol
			buffer << " " << name << '="' << v.name.tr("_", "-").gsub('"', "&quot;") << '"'
		when Integer, Float
			buffer << " " << name << '="' << v.to_s << '"'
		when Hash
			case k
			when :class
				buffer << " " << name << '="' << __classes__(v).gsub('"', "&quot;") << '"'
			when :style
				buffer << " " << name << '="' << __styles__(v).gsub('"', "&quot;") << '"'
			else
				__nested_attributes__(v, "#{name}-", buffer)
			end
		when Array
			value = case k
			when :class
				__classes__(v)
			when :style
				__styles__(v)
			else
				__nested_tokens__(v)
			end
			buffer << " " << name << '="' << value.gsub('"', "&quot;") << '"'
		when Set
			buffer << " " << name << '="' << __nested_tokens__(v.to_a) << '"'
		when Phlex::SGML::SafeObject
			buffer << " " << name << '="' << v.to_s.gsub('"', "&quot;") << '"'
		else
			value = if v.respond_to?(:to_phlex_attribute_value)
				v.to_phlex_attribute_value
			elsif v.respond_to?(:to_str)
				v.to_str
			else
				v.to_s
			end
			buffer << " " << name << '="' << value.gsub('"', "&quot;") << '"'
		end
	end
	buffer
end