module ActionView::Helpers::TagHelper
Constants
- FORM_HELPER_CSS_OPTIONS
Public Instance Methods
content_tag_string_with_css(name, content, options, escape=true)
click to toggle source
# File lib/form_helper_css/form_helper_css.rb, line 45 def content_tag_string_with_css(name, content, options, escape=true) content_tag_string_without_css(name, content, css_options_for_tag(name, options || {}), escape) end
css_options_for_tag(name, options={})
click to toggle source
# File lib/form_helper_css/form_helper_css.rb, line 9 def css_options_for_tag(name, options={}) name = name.to_sym options = options.stringify_keys class_was_array = options['class'].is_a?(Array) options['class'] = options['class'].join(' ') if class_was_array if FORM_HELPER_CSS_OPTIONS[:append] == false && options.has_key?('class') options['class'] = options['class'].split(' ') if class_was_array return options elsif name == :input and options['type'] return options if (options['type'] == 'hidden') if FORM_HELPER_CSS_OPTIONS[:append] && options['class'] options['class'] << ' ' + options['type'].to_s.dup else options['class'] = options['type'].to_s.dup end options['class'] << ' button' if ['submit', 'reset'].include? options['type'] options['class'] << ' text' if options['type'] == 'password' elsif name == :textarea if FORM_HELPER_CSS_OPTIONS[:append] && options['class'] options['class'] << ' text' else options['class'] = 'text' end end if options['class'] options['class'] = options['class'].to_s.strip.split(/\s+/).uniq.join(' ') # de-dup the class list end options['class'] = options['class'].split(' ') if class_was_array options end
tag_with_css(name, options=nil, open=false, escape=true)
click to toggle source
# File lib/form_helper_css/form_helper_css.rb, line 40 def tag_with_css(name, options=nil, open=false, escape=true) tag_without_css(name, css_options_for_tag(name, options || {}), open, escape) end