merb-helpers 1.0.6.1 → 1.0.7
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/lib/merb-helpers/form/builder.rb +28 -17
- data/spec/fixture/app/views/label_specs/basic.html.erb +1 -1
- data/spec/fixture/app/views/label_specs/basic_with_attributes.html.erb +1 -0
- data/spec/fixture/app/views/label_specs/basic_with_class.html.erb +1 -0
- data/spec/merb.main.pid +1 -1
- data/spec/merb_helpers_form_spec.rb +11 -0
- data/spec/merb_test.log +84 -0
- metadata +5 -3
@@ -291,33 +291,44 @@ module Merb::Helpers::Form::Builder
|
|
291
291
|
|
292
292
|
class Form < Base
|
293
293
|
def label(contents, attrs = {})
|
294
|
-
if contents.is_a?(Hash)
|
295
|
-
attrs = contents
|
296
|
-
contents = attrs.delete(:label)
|
297
|
-
end
|
298
294
|
if contents
|
299
|
-
for_attr = attrs[:id] ? {:for => attrs[:id]} : {}
|
300
295
|
if contents.is_a?(Hash)
|
301
|
-
|
302
|
-
contents =
|
303
|
-
|
296
|
+
label_attrs = contents
|
297
|
+
contents = label_attrs.delete(:title)
|
298
|
+
else
|
299
|
+
label_attrs = attrs
|
304
300
|
end
|
305
|
-
tag(:label, contents,
|
301
|
+
tag(:label, contents, label_attrs)
|
306
302
|
else
|
307
303
|
""
|
308
304
|
end
|
309
305
|
end
|
310
|
-
|
306
|
+
|
311
307
|
%w(text password file).each do |kind|
|
312
308
|
self.class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
313
309
|
def unbound_#{kind}_field(attrs = {})
|
314
|
-
|
310
|
+
unbound_label(attrs) + super
|
315
311
|
end
|
316
312
|
RUBY
|
317
313
|
end
|
314
|
+
|
315
|
+
def unbound_label(attrs = {})
|
316
|
+
if attrs[:id]
|
317
|
+
label_attrs = {:for => attrs[:id]}
|
318
|
+
else
|
319
|
+
label_attrs = {}
|
320
|
+
end
|
321
|
+
|
322
|
+
label_option = attrs.delete(:label)
|
323
|
+
if label_option.is_a? Hash
|
324
|
+
label(label_attrs.merge(label_option))
|
325
|
+
else
|
326
|
+
label(label_option, label_attrs)
|
327
|
+
end
|
328
|
+
end
|
318
329
|
|
319
330
|
def unbound_check_box(attrs = {})
|
320
|
-
label_text =
|
331
|
+
label_text = unbound_label(attrs)
|
321
332
|
super + label_text
|
322
333
|
end
|
323
334
|
|
@@ -327,24 +338,24 @@ module Merb::Helpers::Form::Builder
|
|
327
338
|
end
|
328
339
|
|
329
340
|
def unbound_radio_button(attrs = {})
|
330
|
-
label_text =
|
341
|
+
label_text = unbound_label(attrs)
|
331
342
|
super + label_text
|
332
343
|
end
|
333
344
|
|
334
345
|
def unbound_select(attrs = {})
|
335
|
-
|
346
|
+
unbound_label(attrs) + super
|
336
347
|
end
|
337
348
|
|
338
349
|
def unbound_text_area(contents, attrs = {})
|
339
|
-
|
350
|
+
unbound_label(attrs) + super
|
340
351
|
end
|
341
352
|
|
342
353
|
def button(contents, attrs = {})
|
343
|
-
|
354
|
+
unbound_label(attrs) + super
|
344
355
|
end
|
345
356
|
|
346
357
|
def submit(value, attrs = {})
|
347
|
-
|
358
|
+
unbound_label(attrs) + super
|
348
359
|
end
|
349
360
|
|
350
361
|
private
|
@@ -1 +1 @@
|
|
1
|
-
<%= label "First Name", :
|
1
|
+
<%= label "First Name", :for => "user_first_name" %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= label "Email Me", :style => "display:none", :rel => "tooltip" %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= label "Last Name", :class => "name_class" %>
|
data/spec/merb.main.pid
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
2424
|
@@ -1050,6 +1050,17 @@ describe "label" do
|
|
1050
1050
|
r = @c.render :basic
|
1051
1051
|
r.should have_selector("label[for=user_first_name]:contains('First Name')")
|
1052
1052
|
end
|
1053
|
+
|
1054
|
+
it "should render a label tag with a :class attribute set" do
|
1055
|
+
r = @c.render :basic_with_class
|
1056
|
+
r.should have_selector("label[class=name_class]")
|
1057
|
+
end
|
1058
|
+
|
1059
|
+
it "should render a label tag with both rel and style attributes set" do
|
1060
|
+
r = @c.render :basic_with_attributes
|
1061
|
+
r.should have_selector("label[rel=tooltip][style='display:none']")
|
1062
|
+
end
|
1063
|
+
|
1053
1064
|
end
|
1054
1065
|
|
1055
1066
|
describe "file_field" do
|
data/spec/merb_test.log
CHANGED
@@ -61,3 +61,87 @@
|
|
61
61
|
~ {:after_filters_time=>6.0e-06, :dispatch_time=>0.000648, :before_filters_time=>5.0e-06, :action_time=>0.000453}
|
62
62
|
~
|
63
63
|
|
64
|
+
~ Compiling routes...
|
65
|
+
~ Started request handling: Sun Dec 28 15:34:54 -0800 2008
|
66
|
+
~ Params: {"format"=>nil, "action"=>"tag_with_content", "id"=>nil, "controller"=>"tag_helper"}
|
67
|
+
~ {:after_filters_time=>2.7e-05, :dispatch_time=>0.001595, :before_filters_time=>2.8e-05, :action_time=>0.001066}
|
68
|
+
~
|
69
|
+
|
70
|
+
~ Started request handling: Sun Dec 28 15:34:54 -0800 2008
|
71
|
+
~ Params: {"format"=>nil, "action"=>"tag_with_content_in_the_block", "id"=>nil, "controller"=>"tag_helper"}
|
72
|
+
~ {:after_filters_time=>9.0e-06, :dispatch_time=>0.001147, :before_filters_time=>1.3e-05, :action_time=>0.000678}
|
73
|
+
~
|
74
|
+
|
75
|
+
~ Started request handling: Sun Dec 28 15:34:54 -0800 2008
|
76
|
+
~ Params: {"format"=>nil, "action"=>"tag_with_attributes", "id"=>nil, "controller"=>"tag_helper"}
|
77
|
+
~ {:after_filters_time=>9.0e-06, :dispatch_time=>0.000981, :before_filters_time=>1.1e-05, :action_time=>0.000637}
|
78
|
+
~
|
79
|
+
|
80
|
+
~ Started request handling: Sun Dec 28 15:34:54 -0800 2008
|
81
|
+
~ Params: {"format"=>nil, "action"=>"nested_tags", "id"=>nil, "controller"=>"tag_helper"}
|
82
|
+
~ {:after_filters_time=>8.0e-06, :dispatch_time=>0.001034, :before_filters_time=>1.0e-05, :action_time=>0.000735}
|
83
|
+
~
|
84
|
+
|
85
|
+
~ Compiling routes...
|
86
|
+
~ Started request handling: Sun Dec 28 15:35:38 -0800 2008
|
87
|
+
~ Params: {"format"=>nil, "action"=>"tag_with_content", "id"=>nil, "controller"=>"tag_helper"}
|
88
|
+
~ {:after_filters_time=>1.4e-05, :dispatch_time=>0.0009, :before_filters_time=>1.5e-05, :action_time=>0.000615}
|
89
|
+
~
|
90
|
+
|
91
|
+
~ Started request handling: Sun Dec 28 15:35:38 -0800 2008
|
92
|
+
~ Params: {"format"=>nil, "action"=>"tag_with_content_in_the_block", "id"=>nil, "controller"=>"tag_helper"}
|
93
|
+
~ {:after_filters_time=>4.0e-06, :dispatch_time=>0.000585, :before_filters_time=>6.0e-06, :action_time=>0.000357}
|
94
|
+
~
|
95
|
+
|
96
|
+
~ Started request handling: Sun Dec 28 15:35:38 -0800 2008
|
97
|
+
~ Params: {"format"=>nil, "action"=>"tag_with_attributes", "id"=>nil, "controller"=>"tag_helper"}
|
98
|
+
~ {:after_filters_time=>5.0e-06, :dispatch_time=>0.000523, :before_filters_time=>5.0e-06, :action_time=>0.000346}
|
99
|
+
~
|
100
|
+
|
101
|
+
~ Started request handling: Sun Dec 28 15:35:38 -0800 2008
|
102
|
+
~ Params: {"format"=>nil, "action"=>"nested_tags", "id"=>nil, "controller"=>"tag_helper"}
|
103
|
+
~ {:after_filters_time=>6.0e-06, :dispatch_time=>0.000693, :before_filters_time=>7.0e-06, :action_time=>0.000497}
|
104
|
+
~
|
105
|
+
|
106
|
+
~ Compiling routes...
|
107
|
+
~ Started request handling: Sun Dec 28 15:56:42 -0800 2008
|
108
|
+
~ Params: {"format"=>nil, "action"=>"tag_with_content", "id"=>nil, "controller"=>"tag_helper"}
|
109
|
+
~ {:after_filters_time=>2.9e-05, :dispatch_time=>0.001609, :before_filters_time=>1.8e-05, :action_time=>0.001234}
|
110
|
+
~
|
111
|
+
|
112
|
+
~ Started request handling: Sun Dec 28 15:56:42 -0800 2008
|
113
|
+
~ Params: {"format"=>nil, "action"=>"tag_with_content_in_the_block", "id"=>nil, "controller"=>"tag_helper"}
|
114
|
+
~ {:after_filters_time=>6.0e-06, :dispatch_time=>0.000784, :before_filters_time=>9.0e-06, :action_time=>0.0005}
|
115
|
+
~
|
116
|
+
|
117
|
+
~ Started request handling: Sun Dec 28 15:56:42 -0800 2008
|
118
|
+
~ Params: {"format"=>nil, "action"=>"tag_with_attributes", "id"=>nil, "controller"=>"tag_helper"}
|
119
|
+
~ {:after_filters_time=>7.0e-06, :dispatch_time=>0.001473, :before_filters_time=>1.2e-05, :action_time=>0.000754}
|
120
|
+
~
|
121
|
+
|
122
|
+
~ Started request handling: Sun Dec 28 15:56:42 -0800 2008
|
123
|
+
~ Params: {"format"=>nil, "action"=>"nested_tags", "id"=>nil, "controller"=>"tag_helper"}
|
124
|
+
~ {:after_filters_time=>1.5e-05, :dispatch_time=>0.002152, :before_filters_time=>1.9e-05, :action_time=>0.001482}
|
125
|
+
~
|
126
|
+
|
127
|
+
~ Compiling routes...
|
128
|
+
~ Started request handling: Sun Dec 28 16:32:08 -0800 2008
|
129
|
+
~ Params: {"format"=>nil, "action"=>"tag_with_content", "id"=>nil, "controller"=>"tag_helper"}
|
130
|
+
~ {:after_filters_time=>1.7e-05, :dispatch_time=>0.001518, :before_filters_time=>1.4e-05, :action_time=>0.001218}
|
131
|
+
~
|
132
|
+
|
133
|
+
~ Started request handling: Sun Dec 28 16:32:08 -0800 2008
|
134
|
+
~ Params: {"format"=>nil, "action"=>"tag_with_content_in_the_block", "id"=>nil, "controller"=>"tag_helper"}
|
135
|
+
~ {:after_filters_time=>5.0e-06, :dispatch_time=>0.000514, :before_filters_time=>5.0e-06, :action_time=>0.000269}
|
136
|
+
~
|
137
|
+
|
138
|
+
~ Started request handling: Sun Dec 28 16:32:08 -0800 2008
|
139
|
+
~ Params: {"format"=>nil, "action"=>"tag_with_attributes", "id"=>nil, "controller"=>"tag_helper"}
|
140
|
+
~ {:after_filters_time=>4.0e-06, :dispatch_time=>0.00042, :before_filters_time=>5.0e-06, :action_time=>0.000234}
|
141
|
+
~
|
142
|
+
|
143
|
+
~ Started request handling: Sun Dec 28 16:32:08 -0800 2008
|
144
|
+
~ Params: {"format"=>nil, "action"=>"nested_tags", "id"=>nil, "controller"=>"tag_helper"}
|
145
|
+
~ {:after_filters_time=>5.0e-06, :dispatch_time=>0.00055, :before_filters_time=>1.0e-05, :action_time=>0.000352}
|
146
|
+
~
|
147
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: merb-helpers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael D. Ivey
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-12-
|
12
|
+
date: 2008-12-28 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -20,7 +20,7 @@ dependencies:
|
|
20
20
|
requirements:
|
21
21
|
- - ">="
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: 1.0.
|
23
|
+
version: 1.0.7
|
24
24
|
version:
|
25
25
|
description: Helper support for Merb
|
26
26
|
email: ivey@gweezlebur.com
|
@@ -210,6 +210,8 @@ files:
|
|
210
210
|
- spec/fixture/app/views/hidden_field_specs/label.html.erb
|
211
211
|
- spec/fixture/app/views/label_specs
|
212
212
|
- spec/fixture/app/views/label_specs/basic.html.erb
|
213
|
+
- spec/fixture/app/views/label_specs/basic_with_attributes.html.erb
|
214
|
+
- spec/fixture/app/views/label_specs/basic_with_class.html.erb
|
213
215
|
- spec/fixture/app/views/layout
|
214
216
|
- spec/fixture/app/views/layout/application.html.erb
|
215
217
|
- spec/fixture/app/views/numeric_ext_specs
|