erb_form 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/erb_form/builder.rb +6 -2
- data/lib/erb_form/version.rb +1 -1
- data/spec/test_app/app/views/blogs/name_field.html.erb +1 -1
- data/spec/test_app/app/views/blogs/render_input_as_different_type.html.erb +5 -0
- data/spec/test_app/spec/views/blogs/render_input_as_different_type.html.erb_spec +21 -0
- metadata +8 -4
data/lib/erb_form/builder.rb
CHANGED
@@ -47,7 +47,7 @@ module ErbForm
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def locals(attribute_name, options)
|
50
|
-
options.except(:form, :attribute_name, :error, :hint, :input, :label).tap { |o|
|
50
|
+
options.except(:form, :attribute_name, :as, :error, :hint, :input, :label).tap { |o|
|
51
51
|
o[:form] = self
|
52
52
|
o[:attribute_name] = attribute_name
|
53
53
|
o[:error_options] = simplify_options(:error, options)
|
@@ -70,13 +70,17 @@ module ErbForm
|
|
70
70
|
def simplify_options(key, options = {})
|
71
71
|
newkey = case key
|
72
72
|
when :error
|
73
|
+
locals = { :error_prefix => options[:error] }
|
73
74
|
:error_prefix
|
74
75
|
when :input
|
76
|
+
locals = { :input_html => options[:input] }
|
77
|
+
locals[:as] = options[:as] if options.has_key?(:as)
|
75
78
|
:input_html
|
76
79
|
else
|
80
|
+
locals = { key => options[key] }
|
77
81
|
key
|
78
82
|
end
|
79
|
-
options[key].is_a?(Hash) && newkey == key ? options[key] :
|
83
|
+
options[key].is_a?(Hash) && newkey == key ? options[key] : locals
|
80
84
|
end
|
81
85
|
end
|
82
86
|
|
data/lib/erb_form/version.rb
CHANGED
@@ -0,0 +1,21 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "blogs/render_input_as_different_type" do
|
4
|
+
before(:each) do
|
5
|
+
assign(:blog, stub_model(Blog,
|
6
|
+
:name => "",
|
7
|
+
).as_new_record)
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "when the as option is passed" do
|
11
|
+
it "finds the correct layout file" do
|
12
|
+
render
|
13
|
+
rendered.should have_selector "div", :class => "blogs_name_field"
|
14
|
+
end
|
15
|
+
|
16
|
+
it "renders the input as that type" do
|
17
|
+
render
|
18
|
+
rendered.should have_selector "input", :type => 'checkbox'
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: erb_form
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
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: 2012-02-
|
12
|
+
date: 2012-02-24 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: simple_form
|
16
|
-
requirement: &
|
16
|
+
requirement: &2152499440 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: 2.0.0.rc
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2152499440
|
25
25
|
description: Wrap form helper methods in re-usable erb templates.
|
26
26
|
email:
|
27
27
|
- 23inhouse@gmail.com
|
@@ -55,6 +55,7 @@ files:
|
|
55
55
|
- spec/test_app/app/views/blogs/missing_layout_template_error.html.erb
|
56
56
|
- spec/test_app/app/views/blogs/name_field.html.erb
|
57
57
|
- spec/test_app/app/views/blogs/render_field_with_extra_options.html.erb
|
58
|
+
- spec/test_app/app/views/blogs/render_input_as_different_type.html.erb
|
58
59
|
- spec/test_app/app/views/blogs/render_multiple_layouts.html.erb
|
59
60
|
- spec/test_app/app/views/blogs/render_simple_form_with_options.html.erb
|
60
61
|
- spec/test_app/app/views/blogs/render_with_simple_form.html.erb
|
@@ -91,6 +92,7 @@ files:
|
|
91
92
|
- spec/test_app/spec/views/blogs/missing_attribute_template_error.html.erb_spec.rb
|
92
93
|
- spec/test_app/spec/views/blogs/missing_layout_template_error.html.erb_spec.rb
|
93
94
|
- spec/test_app/spec/views/blogs/render_field_with_extra_options.html.erb_spec.rb
|
95
|
+
- spec/test_app/spec/views/blogs/render_input_as_different_type.html.erb_spec
|
94
96
|
- spec/test_app/spec/views/blogs/render_multiple_layouts.html.erb_spec.rb
|
95
97
|
- spec/test_app/spec/views/blogs/render_simple_form_with_options.html.erb_spec.rb
|
96
98
|
- spec/test_app/spec/views/blogs/render_with_simple_form.html.erb_spec.rb
|
@@ -138,6 +140,7 @@ test_files:
|
|
138
140
|
- spec/test_app/app/views/blogs/missing_layout_template_error.html.erb
|
139
141
|
- spec/test_app/app/views/blogs/name_field.html.erb
|
140
142
|
- spec/test_app/app/views/blogs/render_field_with_extra_options.html.erb
|
143
|
+
- spec/test_app/app/views/blogs/render_input_as_different_type.html.erb
|
141
144
|
- spec/test_app/app/views/blogs/render_multiple_layouts.html.erb
|
142
145
|
- spec/test_app/app/views/blogs/render_simple_form_with_options.html.erb
|
143
146
|
- spec/test_app/app/views/blogs/render_with_simple_form.html.erb
|
@@ -174,6 +177,7 @@ test_files:
|
|
174
177
|
- spec/test_app/spec/views/blogs/missing_attribute_template_error.html.erb_spec.rb
|
175
178
|
- spec/test_app/spec/views/blogs/missing_layout_template_error.html.erb_spec.rb
|
176
179
|
- spec/test_app/spec/views/blogs/render_field_with_extra_options.html.erb_spec.rb
|
180
|
+
- spec/test_app/spec/views/blogs/render_input_as_different_type.html.erb_spec
|
177
181
|
- spec/test_app/spec/views/blogs/render_multiple_layouts.html.erb_spec.rb
|
178
182
|
- spec/test_app/spec/views/blogs/render_simple_form_with_options.html.erb_spec.rb
|
179
183
|
- spec/test_app/spec/views/blogs/render_with_simple_form.html.erb_spec.rb
|