form_helper_css 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +4 -0
- data/lib/form_helper_css/form_helper_css.rb +4 -0
- data/lib/form_helper_css/version.rb +1 -1
- data/test/form_helper_css_test.rb +6 -1
- metadata +16 -5
data/Gemfile
CHANGED
@@ -9,7 +9,10 @@ module ActionView
|
|
9
9
|
def css_options_for_tag(name, options={})
|
10
10
|
name = name.to_sym
|
11
11
|
options = options.stringify_keys
|
12
|
+
class_was_array = options['class'].is_a?(Array)
|
13
|
+
options['class'] = options['class'].join(' ') if class_was_array
|
12
14
|
if FORM_HELPER_CSS_OPTIONS[:append] == false && options.has_key?('class')
|
15
|
+
options['class'] = options['class'].split(' ') if class_was_array
|
13
16
|
return options
|
14
17
|
elsif name == :input and options['type']
|
15
18
|
return options if (options['type'] == 'hidden')
|
@@ -30,6 +33,7 @@ module ActionView
|
|
30
33
|
if options['class']
|
31
34
|
options['class'] = options['class'].to_s.strip.split(/\s+/).uniq.join(' ') # de-dup the class list
|
32
35
|
end
|
36
|
+
options['class'] = options['class'].split(' ') if class_was_array
|
33
37
|
options
|
34
38
|
end
|
35
39
|
|
@@ -19,7 +19,7 @@ class FormHelperCssTest < Test::Unit::TestCase
|
|
19
19
|
assert_equal '<br />', tag(:br)
|
20
20
|
assert_equal '<p></p>', content_tag(:p, '')
|
21
21
|
assert_equal '<input type="text" />', tag(:input, :type => 'text', :class => nil)
|
22
|
-
assert_equal
|
22
|
+
assert_equal "<textarea>\n</textarea>", content_tag(:textarea, '', :class => nil)
|
23
23
|
end
|
24
24
|
|
25
25
|
def test_url_helper
|
@@ -66,6 +66,11 @@ class FormHelperCssTest < Test::Unit::TestCase
|
|
66
66
|
assert_match 'class="foo text"', text_field_tag('text', nil, :class => 'foo')
|
67
67
|
end
|
68
68
|
|
69
|
+
def test_css_options_for_tag_with_class_array
|
70
|
+
ActionView::Helpers::TagHelper::FORM_HELPER_CSS_OPTIONS.merge!(:append => true)
|
71
|
+
assert_equal ['foo', 'bar', 'checkbox'], css_options_for_tag('input', :type => 'checkbox', :class => ['foo', :bar])['class']
|
72
|
+
end
|
73
|
+
|
69
74
|
|
70
75
|
def test_form_helper
|
71
76
|
assert_match 'class="checkbox"', check_box(:object, :field)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: form_helper_css
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-01-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,12 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
25
30
|
description: ! 'This plugin enhances the default tag helpers to automatically add
|
26
31
|
CSS classes
|
27
32
|
|
@@ -62,15 +67,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
62
67
|
- - ! '>='
|
63
68
|
- !ruby/object:Gem::Version
|
64
69
|
version: '0'
|
70
|
+
segments:
|
71
|
+
- 0
|
72
|
+
hash: -2897747996719203896
|
65
73
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
74
|
none: false
|
67
75
|
requirements:
|
68
76
|
- - ! '>='
|
69
77
|
- !ruby/object:Gem::Version
|
70
78
|
version: '0'
|
79
|
+
segments:
|
80
|
+
- 0
|
81
|
+
hash: -2897747996719203896
|
71
82
|
requirements: []
|
72
83
|
rubyforge_project: form_helper_css
|
73
|
-
rubygems_version: 1.8.
|
84
|
+
rubygems_version: 1.8.24
|
74
85
|
signing_key:
|
75
86
|
specification_version: 3
|
76
87
|
summary: enhances the default tag helpers to automatically add CSS classes to form
|