Module: ActionView::Helpers::TagHelper
- Defined in:
- lib/form_helper_css/form_helper_css.rb
Constant Summary collapse
- FORM_HELPER_CSS_OPTIONS =
{:append => false}
Instance Method Summary collapse
- #content_tag_string_with_css(name, content, options, escape = true) ⇒ Object
- #css_options_for_tag(name, options = {}) ⇒ Object
- #tag_with_css(name, options = nil, open = false, escape = true) ⇒ Object
Instance Method Details
#content_tag_string_with_css(name, content, options, escape = true) ⇒ Object
45 46 47 |
# File 'lib/form_helper_css/form_helper_css.rb', line 45 def content_tag_string_with_css(name, content, , escape=true) content_tag_string_without_css(name, content, (name, || {}), escape) end |
#css_options_for_tag(name, options = {}) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/form_helper_css/form_helper_css.rb', line 9 def (name, ={}) name = name.to_sym = .stringify_keys class_was_array = ['class'].is_a?(Array) ['class'] = ['class'].join(' ') if class_was_array if FORM_HELPER_CSS_OPTIONS[:append] == false && .has_key?('class') ['class'] = ['class'].split(' ') if class_was_array return elsif name == :input and ['type'] return if (['type'] == 'hidden') if FORM_HELPER_CSS_OPTIONS[:append] && ['class'] ['class'] << ' ' + ['type'].to_s.dup else ['class'] = ['type'].to_s.dup end ['class'] << ' button' if ['submit', 'reset'].include? ['type'] ['class'] << ' text' if ['type'] == 'password' elsif name == :textarea if FORM_HELPER_CSS_OPTIONS[:append] && ['class'] ['class'] << ' text' else ['class'] = 'text' end end if ['class'] ['class'] = ['class'].to_s.strip.split(/\s+/).uniq.join(' ') # de-dup the class list end ['class'] = ['class'].split(' ') if class_was_array end |
#tag_with_css(name, options = nil, open = false, escape = true) ⇒ Object
40 41 42 |
# File 'lib/form_helper_css/form_helper_css.rb', line 40 def tag_with_css(name, =nil, open=false, escape=true) tag_without_css(name, (name, || {}), open, escape) end |