Class: Hash

Inherits:
Object
  • Object
show all
Defined in:
lib/sinatra/tags.rb

Overview

:stopdoc:

Instance Method Summary collapse

Instance Method Details

#to_html_attributes(include_empties = nil) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/sinatra/tags.rb', line 10

def to_html_attributes(include_empties=nil)
  hash = self.dup
  hash.reject! {|k,v| v.blank? } unless include_empties.nil?
  out = ''
  hash.keys.each do |key|
    val = hash[key].is_a?(Array) ? hash[key].join('_') : hash[key].to_s
    out << "#{key.to_s}=\"#{val}\" "
  end
  out.strip
end