Module: InputCSS
- Included in:
- ActionView::Helpers::TagHelper
- Defined in:
- lib/input_css.rb,
lib/input_css/version.rb
Overview
Modifies the ‘options’ of the tag helper so that, by default, there’s a CSS class attribute based on the type attribute (Note: only applies to input fields)
Constant Summary collapse
- VERSION =
"0.2.0"
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.css_options_for_tag(name, options) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/input_css.rb', line 14 def (name, ) = HashWithIndifferentAccess.new() return if [:type] == 'hidden' # alter CSS class based on type # (only for <input ... /> tags) if name.to_s.downcase =~ /^input$/ type, css = [:type], [:class] type = 'text' if type == 'password' [:class] = "#{css.to_s} #{type.to_s}".gsub!(/^\s*/, '') unless css && css.split.include?(type) end end |
Instance Method Details
#tag(name = nil, options = nil, open = false, escape = true) ⇒ Object
7 8 9 10 11 12 |
# File 'lib/input_css.rb', line 7 def tag(name=nil, =nil, open=false, escape=true) if name.present? = (name, ) end super end |