Sha256: 44fe0fda57e118c2ccb4e851105edbcc49ccaa6dd14a9382bcf34ea76117e026
Contents?: true
Size: 508 Bytes
Versions: 10
Compression:
Stored size: 508 Bytes
Contents
module Arbre module HTML class Attributes < Hash def to_s map do |name, value| next if value_empty?(value) "#{html_escape(name)}=\"#{html_escape(value)}\"" end.compact.join ' ' end def any? super{ |k,v| !value_empty?(v) } end protected def value_empty?(value) value.respond_to?(:empty?) ? value.empty? : !value end def html_escape(s) ERB::Util.html_escape(s) end end end end
Version data entries
10 entries across 10 versions & 2 rubygems