Adds the given class symbol or string to the hash in the :class key. This will add a html class if there are already any existing or create the key and add this as the first class
@hash[:class] #=> nil @hash.add_html_class!(:selected) #=> @hash[:class] == "selected" @hash.add_html_class!("class1 class2") #=> @hash[:class] == "selected class1 class2"
Source Code
# File merb/core_ext/hash.rb, line 152 def add_html_class!(html_class) if self[:class] self[:class] = "#{self[:class]} #{html_class}" else self[:class] = html_class.to_s end end
<code/>and<pre/>for code samples.