campo 0.3.1 → 0.3.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.tar.gz.sig +0 -0
- data/CHANGES +2 -0
- data/README.markdown +1 -1
- data/lib/campo.rb +8 -7
- data/lib/campo/version.rb +1 -1
- data/spec/campo_spec.rb +83 -20
- metadata +4 -4
- metadata.gz.sig +0 -0
data.tar.gz.sig
CHANGED
Binary file
|
data/CHANGES
CHANGED
data/README.markdown
CHANGED
@@ -387,7 +387,7 @@ Note: I'm considering making this an instance variable so that it can be passed
|
|
387
387
|
Most fields will accept a block, so you can nest whatever you like. Generally I just use this for forms, fieldsets and selects (and those have specs) but if you want to try something new, do it! Let me know if it breaks.
|
388
388
|
|
389
389
|
form = Campo.literal "%div" do |div|
|
390
|
-
div.form "nested" do |form|
|
390
|
+
div << Campo.form( "nested" ) do |form|
|
391
391
|
form.fieldset do |f|
|
392
392
|
f.select "blurg" do |s|
|
393
393
|
s.option "oopsie"
|
data/lib/campo.rb
CHANGED
@@ -37,8 +37,8 @@ module Campo
|
|
37
37
|
|
38
38
|
# @example Add a bit of code to the markup
|
39
39
|
# form.bit_of_ruby( "= 5 + 1" ) }
|
40
|
-
def bit_of_ruby( *args )
|
41
|
-
tag = Campo::Haml_Ruby_Insert.new( *args )
|
40
|
+
def bit_of_ruby( *args, &block )
|
41
|
+
tag = Campo::Haml_Ruby_Insert.new( *args, &block )
|
42
42
|
self << tag
|
43
43
|
tag
|
44
44
|
end
|
@@ -47,8 +47,8 @@ module Campo
|
|
47
47
|
|
48
48
|
# @example Output a literal string
|
49
49
|
# form.literal %Q!%p= "This is a paragraph "!
|
50
|
-
def literal( *args )
|
51
|
-
tag = Campo::Literal.new( *args )
|
50
|
+
def literal( *args, &block )
|
51
|
+
tag = Campo::Literal.new( *args, &block )
|
52
52
|
self << tag
|
53
53
|
tag
|
54
54
|
end
|
@@ -83,8 +83,8 @@ module Campo
|
|
83
83
|
# f.text "dob", "Date of birth: ", size: 8
|
84
84
|
# @return [Input]
|
85
85
|
# With the attribute `type=text`
|
86
|
-
def text( name, label=nil, attributes={}
|
87
|
-
input( name, :text, label, attributes
|
86
|
+
def text( name, label=nil, attributes={} )
|
87
|
+
input( name, :text, label, attributes )
|
88
88
|
end
|
89
89
|
|
90
90
|
# @param (see #text)
|
@@ -120,7 +120,7 @@ module Campo
|
|
120
120
|
end
|
121
121
|
|
122
122
|
|
123
|
-
def textarea( *args )
|
123
|
+
def textarea( *args, &block )
|
124
124
|
textarea = Campo::Textarea.new( *args )
|
125
125
|
self << textarea
|
126
126
|
textarea
|
@@ -278,6 +278,7 @@ STR
|
|
278
278
|
# #... more fields follow
|
279
279
|
# end
|
280
280
|
def initialize(name, attributes={} )
|
281
|
+
attributes[:id] = name.gsub(/\W/, "_") if attributes[:id].nil?
|
281
282
|
super( name, DEFAULT.merge( attributes ) )
|
282
283
|
self.on_output do |n=0, tab=2|
|
283
284
|
%Q!#{" " * n * tab}%form{ atts[:#{name.gsub(/\W/, "_").downcase}], #{Base.unhash( @attributes )} }!
|
data/lib/campo/version.rb
CHANGED
data/spec/campo_spec.rb
CHANGED
@@ -31,7 +31,7 @@ STR
|
|
31
31
|
describe :output do
|
32
32
|
context "Given a form with no fields" do
|
33
33
|
let(:expected) {
|
34
|
-
expected = top_bit + %q!%form{ atts[:myform], method: "POST", name: "myform", }!.strip + "\n"
|
34
|
+
expected = top_bit + %q!%form{ atts[:myform], method: "POST", id: "myform", name: "myform", }!.strip + "\n"
|
35
35
|
}
|
36
36
|
|
37
37
|
subject{ Campo.output Campo::Form.new( "myform" ) }
|
@@ -92,7 +92,7 @@ STR
|
|
92
92
|
|
93
93
|
|
94
94
|
let(:expected) {
|
95
|
-
%Q!- atts = {} if atts.nil?\n- atts.default = {} if atts.default.nil?\n- inners = {} if inners.nil?\n- inners.default = "" if inners.default.nil?\n- i = 0 # for tabindex\n\n%form{ atts[:personal_details], method: "POST", action: uri("/my/personal_details/update/"), name: "personal_details", }\n %fieldset{ }\n %legend{ }Your details\n %label{ for: "full_name", }\n Full name: \n %input{ atts[:full_name], tabindex: "\#{i += 1}", type: "text", id: "full_name", size: "60", name: "full_name", }\n %label{ for: "dob", }\n Date of birth: \n %input{ atts[:dob], tabindex: "\#{i += 1}", type: "text", id: "dob", size: "10", name: "dob", }\n %fieldset{ }\n %legend{ }Gender: \n %label{ for: "gender_1", }\n Male\n %input{ atts[:gender_1], tabindex: "\#{i += 1}", type: "radio", id: "gender_1", value: "1", name: "gender", }\n %label{ for: "gender_2", }\n Female\n %input{ atts[:gender_2], tabindex: "\#{i += 1}", type: "radio", id: "gender_2", value: "2", name: "gender", }\n %label{ for: "ethnicorigin_id", }\n Ethnic-origin: \n %select{ atts[:ethnicorigin_id], tabindex: "\#{i += 1}", name: "ethnicorigin_id", }\n %option{ value: "", disabled: "disabled", name: "ethnicorigin_id", }Choose one:\n %option{ atts[:ethnicorigin_id_1], value: "1", id: "ethnicorigin_id_1", name: "ethnicorigin_id", }White\n %option{ atts[:ethnicorigin_id_2], value: "2", id: "ethnicorigin_id_2", name: "ethnicorigin_id", }Asian\n %option{ atts[:ethnicorigin_id_3], value: "3", id: "ethnicorigin_id_3", name: "ethnicorigin_id", }Black\n %option{ atts[:ethnicorigin_id_4], value: "4", id: "ethnicorigin_id_4", name: "ethnicorigin_id", }Chinese and Other\n %option{ atts[:ethnicorigin_id_5], value: "5", id: "ethnicorigin_id_5", name: "ethnicorigin_id", }Mixed\n %label{ for: "occupation", }\n Occupation: \n %input{ atts[:occupation], tabindex: "\#{i += 1}", type: "text", id: "occupation", size: "60", name: "occupation", }\n %label{ for: "phone_landline", }\n Phone (landline): \n %input{ atts[:phone_landline], tabindex: "\#{i += 1}", type: "text", id: "phone_landline", size: "20", name: "phone_landline", }\n %label{ for: "phone_mobile", }\n Phone (mobile): \n %input{ atts[:phone_mobile], tabindex: "\#{i += 1}", type: "text", id: "phone_mobile", size: "20", name: "phone_mobile", }\n %fieldset{ }\n %legend{ }May we contact you...\n %label{ for: "contactable_day", }\n In the day?\n %input{ atts[:contactable_day], tabindex: "\#{i += 1}", type: "checkbox", id: "contactable_day", value: "day", name: "contactable", }\n %label{ for: "contactable_evening", }\n In the evening?\n %input{ atts[:contactable_evening], tabindex: "\#{i += 1}", type: "checkbox", id: "contactable_evening", value: "evening", name: "contactable", }\n %input{ atts[:Save_Save], tabindex: "\#{i += 1}", type: "submit", id: "Save_Save", value: "Save", }\n!
|
95
|
+
%Q!- atts = {} if atts.nil?\n- atts.default = {} if atts.default.nil?\n- inners = {} if inners.nil?\n- inners.default = "" if inners.default.nil?\n- i = 0 # for tabindex\n\n%form{ atts[:personal_details], method: "POST", action: uri("/my/personal_details/update/"), id: "personal_details", name: "personal_details", }\n %fieldset{ }\n %legend{ }Your details\n %label{ for: "full_name", }\n Full name: \n %input{ atts[:full_name], tabindex: "\#{i += 1}", type: "text", id: "full_name", size: "60", name: "full_name", }\n %label{ for: "dob", }\n Date of birth: \n %input{ atts[:dob], tabindex: "\#{i += 1}", type: "text", id: "dob", size: "10", name: "dob", }\n %fieldset{ }\n %legend{ }Gender: \n %label{ for: "gender_1", }\n Male\n %input{ atts[:gender_1], tabindex: "\#{i += 1}", type: "radio", id: "gender_1", value: "1", name: "gender", }\n %label{ for: "gender_2", }\n Female\n %input{ atts[:gender_2], tabindex: "\#{i += 1}", type: "radio", id: "gender_2", value: "2", name: "gender", }\n %label{ for: "ethnicorigin_id", }\n Ethnic-origin: \n %select{ atts[:ethnicorigin_id], tabindex: "\#{i += 1}", name: "ethnicorigin_id", }\n %option{ value: "", disabled: "disabled", name: "ethnicorigin_id", }Choose one:\n %option{ atts[:ethnicorigin_id_1], value: "1", id: "ethnicorigin_id_1", name: "ethnicorigin_id", }White\n %option{ atts[:ethnicorigin_id_2], value: "2", id: "ethnicorigin_id_2", name: "ethnicorigin_id", }Asian\n %option{ atts[:ethnicorigin_id_3], value: "3", id: "ethnicorigin_id_3", name: "ethnicorigin_id", }Black\n %option{ atts[:ethnicorigin_id_4], value: "4", id: "ethnicorigin_id_4", name: "ethnicorigin_id", }Chinese and Other\n %option{ atts[:ethnicorigin_id_5], value: "5", id: "ethnicorigin_id_5", name: "ethnicorigin_id", }Mixed\n %label{ for: "occupation", }\n Occupation: \n %input{ atts[:occupation], tabindex: "\#{i += 1}", type: "text", id: "occupation", size: "60", name: "occupation", }\n %label{ for: "phone_landline", }\n Phone (landline): \n %input{ atts[:phone_landline], tabindex: "\#{i += 1}", type: "text", id: "phone_landline", size: "20", name: "phone_landline", }\n %label{ for: "phone_mobile", }\n Phone (mobile): \n %input{ atts[:phone_mobile], tabindex: "\#{i += 1}", type: "text", id: "phone_mobile", size: "20", name: "phone_mobile", }\n %fieldset{ }\n %legend{ }May we contact you...\n %label{ for: "contactable_day", }\n In the day?\n %input{ atts[:contactable_day], tabindex: "\#{i += 1}", type: "checkbox", id: "contactable_day", value: "day", name: "contactable", }\n %label{ for: "contactable_evening", }\n In the evening?\n %input{ atts[:contactable_evening], tabindex: "\#{i += 1}", type: "checkbox", id: "contactable_evening", value: "evening", name: "contactable", }\n %input{ atts[:Save_Save], tabindex: "\#{i += 1}", type: "submit", id: "Save_Save", value: "Save", }\n!
|
96
96
|
} # let expected
|
97
97
|
|
98
98
|
subject{ Campo.output form }
|
@@ -106,7 +106,7 @@ STR
|
|
106
106
|
end
|
107
107
|
}
|
108
108
|
let(:expected) {
|
109
|
-
%Q!- atts = {} if atts.nil?\n- atts.default = {} if atts.default.nil?\n- inners = {} if inners.nil?\n- inners.default = "" if inners.default.nil?\n- i = 0 # for tabindex\n\n.centred.form\n %form{ atts[:personal_details], method: "POST", action: uri("/my/personal_details/update/"), name: "personal_details", }\n %fieldset{ }\n %legend{ }Your details\n %label{ for: "full_name", }\n Full name: \n %input{ atts[:full_name], tabindex: "\#{i += 1}", type: "text", id: "full_name", size: "60", name: "full_name", }\n %label{ for: "dob", }\n Date of birth: \n %input{ atts[:dob], tabindex: "\#{i += 1}", type: "text", id: "dob", size: "10", name: "dob", }\n %fieldset{ }\n %legend{ }Gender: \n %label{ for: "gender_1", }\n Male\n %input{ atts[:gender_1], tabindex: "\#{i += 1}", type: "radio", id: "gender_1", value: "1", name: "gender", }\n %label{ for: "gender_2", }\n Female\n %input{ atts[:gender_2], tabindex: "\#{i += 1}", type: "radio", id: "gender_2", value: "2", name: "gender", }\n %label{ for: "ethnicorigin_id", }\n Ethnic-origin: \n %select{ atts[:ethnicorigin_id], tabindex: "\#{i += 1}", name: "ethnicorigin_id", }\n %option{ value: "", disabled: "disabled", name: "ethnicorigin_id", }Choose one:\n %option{ atts[:ethnicorigin_id_1], value: "1", id: "ethnicorigin_id_1", name: "ethnicorigin_id", }White\n %option{ atts[:ethnicorigin_id_2], value: "2", id: "ethnicorigin_id_2", name: "ethnicorigin_id", }Asian\n %option{ atts[:ethnicorigin_id_3], value: "3", id: "ethnicorigin_id_3", name: "ethnicorigin_id", }Black\n %option{ atts[:ethnicorigin_id_4], value: "4", id: "ethnicorigin_id_4", name: "ethnicorigin_id", }Chinese and Other\n %option{ atts[:ethnicorigin_id_5], value: "5", id: "ethnicorigin_id_5", name: "ethnicorigin_id", }Mixed\n %label{ for: "occupation", }\n Occupation: \n %input{ atts[:occupation], tabindex: "\#{i += 1}", type: "text", id: "occupation", size: "60", name: "occupation", }\n %label{ for: "phone_landline", }\n Phone (landline): \n %input{ atts[:phone_landline], tabindex: "\#{i += 1}", type: "text", id: "phone_landline", size: "20", name: "phone_landline", }\n %label{ for: "phone_mobile", }\n Phone (mobile): \n %input{ atts[:phone_mobile], tabindex: "\#{i += 1}", type: "text", id: "phone_mobile", size: "20", name: "phone_mobile", }\n %fieldset{ }\n %legend{ }May we contact you...\n %label{ for: "contactable_day", }\n In the day?\n %input{ atts[:contactable_day], tabindex: "\#{i += 1}", type: "checkbox", id: "contactable_day", value: "day", name: "contactable", }\n %label{ for: "contactable_evening", }\n In the evening?\n %input{ atts[:contactable_evening], tabindex: "\#{i += 1}", type: "checkbox", id: "contactable_evening", value: "evening", name: "contactable", }\n %input{ atts[:Save_Save], tabindex: "\#{i += 1}", type: "submit", id: "Save_Save", value: "Save", }\n!
|
109
|
+
%Q!- atts = {} if atts.nil?\n- atts.default = {} if atts.default.nil?\n- inners = {} if inners.nil?\n- inners.default = "" if inners.default.nil?\n- i = 0 # for tabindex\n\n.centred.form\n %form{ atts[:personal_details], method: "POST", action: uri("/my/personal_details/update/"), id: "personal_details", name: "personal_details", }\n %fieldset{ }\n %legend{ }Your details\n %label{ for: "full_name", }\n Full name: \n %input{ atts[:full_name], tabindex: "\#{i += 1}", type: "text", id: "full_name", size: "60", name: "full_name", }\n %label{ for: "dob", }\n Date of birth: \n %input{ atts[:dob], tabindex: "\#{i += 1}", type: "text", id: "dob", size: "10", name: "dob", }\n %fieldset{ }\n %legend{ }Gender: \n %label{ for: "gender_1", }\n Male\n %input{ atts[:gender_1], tabindex: "\#{i += 1}", type: "radio", id: "gender_1", value: "1", name: "gender", }\n %label{ for: "gender_2", }\n Female\n %input{ atts[:gender_2], tabindex: "\#{i += 1}", type: "radio", id: "gender_2", value: "2", name: "gender", }\n %label{ for: "ethnicorigin_id", }\n Ethnic-origin: \n %select{ atts[:ethnicorigin_id], tabindex: "\#{i += 1}", name: "ethnicorigin_id", }\n %option{ value: "", disabled: "disabled", name: "ethnicorigin_id", }Choose one:\n %option{ atts[:ethnicorigin_id_1], value: "1", id: "ethnicorigin_id_1", name: "ethnicorigin_id", }White\n %option{ atts[:ethnicorigin_id_2], value: "2", id: "ethnicorigin_id_2", name: "ethnicorigin_id", }Asian\n %option{ atts[:ethnicorigin_id_3], value: "3", id: "ethnicorigin_id_3", name: "ethnicorigin_id", }Black\n %option{ atts[:ethnicorigin_id_4], value: "4", id: "ethnicorigin_id_4", name: "ethnicorigin_id", }Chinese and Other\n %option{ atts[:ethnicorigin_id_5], value: "5", id: "ethnicorigin_id_5", name: "ethnicorigin_id", }Mixed\n %label{ for: "occupation", }\n Occupation: \n %input{ atts[:occupation], tabindex: "\#{i += 1}", type: "text", id: "occupation", size: "60", name: "occupation", }\n %label{ for: "phone_landline", }\n Phone (landline): \n %input{ atts[:phone_landline], tabindex: "\#{i += 1}", type: "text", id: "phone_landline", size: "20", name: "phone_landline", }\n %label{ for: "phone_mobile", }\n Phone (mobile): \n %input{ atts[:phone_mobile], tabindex: "\#{i += 1}", type: "text", id: "phone_mobile", size: "20", name: "phone_mobile", }\n %fieldset{ }\n %legend{ }May we contact you...\n %label{ for: "contactable_day", }\n In the day?\n %input{ atts[:contactable_day], tabindex: "\#{i += 1}", type: "checkbox", id: "contactable_day", value: "day", name: "contactable", }\n %label{ for: "contactable_evening", }\n In the evening?\n %input{ atts[:contactable_evening], tabindex: "\#{i += 1}", type: "checkbox", id: "contactable_evening", value: "evening", name: "contactable", }\n %input{ atts[:Save_Save], tabindex: "\#{i += 1}", type: "submit", id: "Save_Save", value: "Save", }\n!
|
110
110
|
} # let expected
|
111
111
|
|
112
112
|
subject{ Campo.output doc }
|
@@ -131,7 +131,7 @@ let(:expected) {
|
|
131
131
|
context "of text" do
|
132
132
|
context "with a label" do
|
133
133
|
let(:expected) { top_bit + %q!
|
134
|
-
%form{ atts[:myform], method: "POST", name: "myform", }
|
134
|
+
%form{ atts[:myform], method: "POST", id: "myform", name: "myform", }
|
135
135
|
%label{ for: "blah_blahdeblah", }
|
136
136
|
Blahd
|
137
137
|
%input{ atts[:blah_blahdeblah], tabindex: "#{i += 1}", type: "text", id: "blah_blahdeblah", value: "blahdeblah", name: "blah", }!.strip + "\n" }
|
@@ -152,7 +152,7 @@ let(:expected) {
|
|
152
152
|
end
|
153
153
|
context "without a label" do
|
154
154
|
let(:expected) { top_bit + %q!
|
155
|
-
%form{ atts[:myform], method: "POST", name: "myform", }
|
155
|
+
%form{ atts[:myform], method: "POST", id: "myform", name: "myform", }
|
156
156
|
%label{ for: "blah_blahdeblah", }
|
157
157
|
Blah
|
158
158
|
%input{ atts[:blah_blahdeblah], tabindex: "#{i += 1}", type: "text", id: "blah_blahdeblah", value: "blahdeblah", name: "blah", }!.strip + "\n" }
|
@@ -176,7 +176,7 @@ let(:expected) {
|
|
176
176
|
end # text
|
177
177
|
context "of checkbox" do
|
178
178
|
let(:expected) { top_bit + %q!
|
179
|
-
%form{ atts[:myform], method: "POST", name: "myform", }
|
179
|
+
%form{ atts[:myform], method: "POST", id: "myform", name: "myform", }
|
180
180
|
%label{ for: "blah_blahdeblah", }
|
181
181
|
Blahd
|
182
182
|
%input{ atts[:blah_blahdeblah], tabindex: "#{i += 1}", type: "checkbox", id: "blah_blahdeblah", value: "blahdeblah", name: "blah", }!.strip + "\n" }
|
@@ -413,7 +413,7 @@ s.chomp
|
|
413
413
|
|
414
414
|
|
415
415
|
context "simple output" do
|
416
|
-
let(:expected) { %q!%form{ atts[:myform], method: "POST", name: "myform", }! }
|
416
|
+
let(:expected) { %q!%form{ atts[:myform], method: "POST", id: "myform", name: "myform", }! }
|
417
417
|
subject { form.output }
|
418
418
|
it { should == expected }
|
419
419
|
end
|
@@ -425,7 +425,7 @@ s.chomp
|
|
425
425
|
it { should be_a_kind_of(Form) }
|
426
426
|
|
427
427
|
context "simple output" do
|
428
|
-
let(:expected) { %q!%form{ atts[:myform], method: "POST", action: "/", name: "myform", }! }
|
428
|
+
let(:expected) { %q!%form{ atts[:myform], method: "POST", action: "/", id: "myform", name: "myform", }! }
|
429
429
|
subject { form.output }
|
430
430
|
it { should == expected }
|
431
431
|
end
|
@@ -438,7 +438,7 @@ s.chomp
|
|
438
438
|
context "When given a form with only a name" do
|
439
439
|
let(:form) { Campo::Form.new( "myform" ) }
|
440
440
|
let(:expected) { top_bit + %q!
|
441
|
-
%form{ atts[:myform], method: "POST", name: "myform", }
|
441
|
+
%form{ atts[:myform], method: "POST", id: "myform", name: "myform", }
|
442
442
|
%fieldset{ }
|
443
443
|
%legend{ }Do you like these colours? Tick for yes:
|
444
444
|
|
@@ -458,7 +458,7 @@ s.chomp
|
|
458
458
|
let(:form) { Campo::Form.new( "myform" ) }
|
459
459
|
context "Given one select tag" do
|
460
460
|
let(:expected) { top_bit + %q!
|
461
|
-
%form{ atts[:myform], method: "POST", name: "myform", }
|
461
|
+
%form{ atts[:myform], method: "POST", id: "myform", name: "myform", }
|
462
462
|
%label{ for: "teas", }
|
463
463
|
Favourite tea:
|
464
464
|
%select{ atts[:teas], tabindex: "#{i += 1}", name: "teas", }
|
@@ -479,7 +479,7 @@ s.chomp
|
|
479
479
|
end
|
480
480
|
context "Given several select tags" do
|
481
481
|
let(:expected) { top_bit + %q!
|
482
|
-
%form{ atts[:myform], method: "POST", name: "myform", }
|
482
|
+
%form{ atts[:myform], method: "POST", id: "myform", name: "myform", }
|
483
483
|
%label{ for: "teas", }
|
484
484
|
Favourite tea:
|
485
485
|
%select{ atts[:teas], tabindex: "#{i += 1}", name: "teas", }
|
@@ -513,7 +513,7 @@ s.chomp
|
|
513
513
|
context "Given a submit button" do
|
514
514
|
context "With no arguments" do
|
515
515
|
let(:expected) { top_bit + %q!
|
516
|
-
%form{ atts[:myform], method: "POST", name: "myform", }
|
516
|
+
%form{ atts[:myform], method: "POST", id: "myform", name: "myform", }
|
517
517
|
%input{ atts[:Submit_Submit], tabindex: "#{i += 1}", type: "submit", id: "Submit_Submit", value: "Submit", }
|
518
518
|
|
519
519
|
!.strip + "\n" }
|
@@ -528,7 +528,7 @@ s.chomp
|
|
528
528
|
end
|
529
529
|
context "With a name" do
|
530
530
|
let(:expected) { top_bit + %q!
|
531
|
-
%form{ atts[:myform], method: "POST", name: "myform", }
|
531
|
+
%form{ atts[:myform], method: "POST", id: "myform", name: "myform", }
|
532
532
|
%input{ atts[:Save_Save], tabindex: "#{i += 1}", type: "submit", id: "Save_Save", value: "Save", }
|
533
533
|
|
534
534
|
!.strip + "\n" }
|
@@ -572,7 +572,7 @@ s.chomp
|
|
572
572
|
|
573
573
|
describe "the full output" do
|
574
574
|
let(:expected) { top_bit + %q$
|
575
|
-
%form{ atts[:myform], method: "POST", name: "myform", }
|
575
|
+
%form{ atts[:myform], method: "POST", id: "myform", name: "myform", }
|
576
576
|
Hello, World!$.strip + "\n"}
|
577
577
|
let(:form){
|
578
578
|
form = Campo::Form.new( "myform" )
|
@@ -582,6 +582,37 @@ s.chomp
|
|
582
582
|
subject { Campo.output form }
|
583
583
|
it { should == expected }
|
584
584
|
end
|
585
|
+
|
586
|
+
context "With a block" do
|
587
|
+
subject {
|
588
|
+
form.literal "%p" do |para|
|
589
|
+
para.literal "Whatever"
|
590
|
+
para.literal "%br"
|
591
|
+
para.literal "you"
|
592
|
+
para.literal "%br"
|
593
|
+
para.literal "think"
|
594
|
+
para.literal "%br"
|
595
|
+
para.literal "challenge"
|
596
|
+
para.literal "%br"
|
597
|
+
para.literal "it"
|
598
|
+
end
|
599
|
+
Campo.output form
|
600
|
+
}
|
601
|
+
let(:expected) { top_bit + %q$%form{ atts[:myform], method: "POST", id: "myform", name: "myform", }
|
602
|
+
%p
|
603
|
+
Whatever
|
604
|
+
%br
|
605
|
+
you
|
606
|
+
%br
|
607
|
+
think
|
608
|
+
%br
|
609
|
+
challenge
|
610
|
+
%br
|
611
|
+
it
|
612
|
+
$.strip + "\n" }
|
613
|
+
it { should_not be_nil }
|
614
|
+
it { should == expected }
|
615
|
+
end
|
585
616
|
end
|
586
617
|
end
|
587
618
|
|
@@ -612,7 +643,7 @@ s.chomp
|
|
612
643
|
|
613
644
|
describe "the full output" do
|
614
645
|
let(:expected) { top_bit + %q!
|
615
|
-
%form{ atts[:myform], method: "POST", name: "myform", }
|
646
|
+
%form{ atts[:myform], method: "POST", id: "myform", name: "myform", }
|
616
647
|
= 5 + 1!.strip + "\n"}
|
617
648
|
let(:form){
|
618
649
|
form = Campo::Form.new( "myform" )
|
@@ -621,6 +652,38 @@ s.chomp
|
|
621
652
|
}
|
622
653
|
subject { Campo.output form }
|
623
654
|
it { should == expected }
|
655
|
+
|
656
|
+
context "With a block" do
|
657
|
+
subject {
|
658
|
+
form.bit_of_ruby %q!="%p"! do |para|
|
659
|
+
para.literal "Whatever"
|
660
|
+
para.literal "%br"
|
661
|
+
para.literal "you"
|
662
|
+
para.literal "%br"
|
663
|
+
para.literal "think"
|
664
|
+
para.literal "%br"
|
665
|
+
para.literal "challenge"
|
666
|
+
para.literal "%br"
|
667
|
+
para.literal "it"
|
668
|
+
end
|
669
|
+
Campo.output form
|
670
|
+
}
|
671
|
+
let(:expected) { top_bit + %q$%form{ atts[:myform], method: "POST", id: "myform", name: "myform", }
|
672
|
+
= 5 + 1
|
673
|
+
="%p"
|
674
|
+
Whatever
|
675
|
+
%br
|
676
|
+
you
|
677
|
+
%br
|
678
|
+
think
|
679
|
+
%br
|
680
|
+
challenge
|
681
|
+
%br
|
682
|
+
it
|
683
|
+
$.strip + "\n" }
|
684
|
+
it { should_not be_nil }
|
685
|
+
it { should == expected }
|
686
|
+
end
|
624
687
|
end
|
625
688
|
end
|
626
689
|
|
@@ -1000,7 +1063,7 @@ s.chomp
|
|
1000
1063
|
context "Labelling" do
|
1001
1064
|
let(:expected) {
|
1002
1065
|
top_bit + %q!
|
1003
|
-
%form{ atts[:myform], method: "POST", name: "myform", }
|
1066
|
+
%form{ atts[:myform], method: "POST", id: "myform", name: "myform", }
|
1004
1067
|
%label{ for: "abc", }
|
1005
1068
|
abc
|
1006
1069
|
%input{ atts[:abc], tabindex: "#{i += 1}", type: "text", id: "abc", name: "abc", }
|
@@ -1027,7 +1090,7 @@ s.chomp
|
|
1027
1090
|
context "Within a fieldset" do
|
1028
1091
|
let(:expected) {
|
1029
1092
|
top_bit + %q!
|
1030
|
-
%form{ atts[:myform], method: "POST", name: "myform", }
|
1093
|
+
%form{ atts[:myform], method: "POST", id: "myform", name: "myform", }
|
1031
1094
|
%fieldset{ }
|
1032
1095
|
%legend{ }Alphabetty spaghetti
|
1033
1096
|
%label{ for: "abc", }
|
@@ -1061,7 +1124,7 @@ s.chomp
|
|
1061
1124
|
describe "A form with a group of radio buttons" do
|
1062
1125
|
let(:expected) {
|
1063
1126
|
top_bit + %q!
|
1064
|
-
%form{ atts[:myform], method: "POST", name: "myform", }
|
1127
|
+
%form{ atts[:myform], method: "POST", id: "myform", name: "myform", }
|
1065
1128
|
%fieldset{ }
|
1066
1129
|
%legend{ }Select the colour you like most:
|
1067
1130
|
%label{ for: "radio1_green", }
|
@@ -1118,7 +1181,7 @@ s.chomp
|
|
1118
1181
|
|
1119
1182
|
describe "the full output" do
|
1120
1183
|
let(:expected) { top_bit + %q!
|
1121
|
-
%form{ atts[:myform], method: "POST", name: "myform", }
|
1184
|
+
%form{ atts[:myform], method: "POST", id: "myform", name: "myform", }
|
1122
1185
|
%textarea{ atts[:textie], tabindex: "#{i += 1}", cols: "40", rows: "10", name: "textie", }= inners[:textie] !.strip + " \n"}
|
1123
1186
|
let(:form){
|
1124
1187
|
form = Campo::Form.new( "myform" )
|
@@ -1143,7 +1206,7 @@ s.chomp
|
|
1143
1206
|
|
1144
1207
|
describe "the full output" do
|
1145
1208
|
let(:expected) { top_bit + %q!
|
1146
|
-
%form{ atts[:myform], method: "POST", name: "myform", }
|
1209
|
+
%form{ atts[:myform], method: "POST", id: "myform", name: "myform", }
|
1147
1210
|
%textarea{ atts[:textie], tabindex: "#{i += 1}", cols: "60", rows: "10", name: "textie", }= inners[:textie]
|
1148
1211
|
!.strip + " \n"}
|
1149
1212
|
let(:form){
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: campo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -50,12 +50,12 @@ cert_chain:
|
|
50
50
|
-----END CERTIFICATE-----
|
51
51
|
|
52
52
|
'
|
53
|
-
date: 2011-
|
53
|
+
date: 2011-12-10 00:00:00.000000000 +00:00
|
54
54
|
default_executable:
|
55
55
|
dependencies:
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: haml
|
58
|
-
requirement: &
|
58
|
+
requirement: &2153759240 !ruby/object:Gem::Requirement
|
59
59
|
none: false
|
60
60
|
requirements:
|
61
61
|
- - ~>
|
@@ -63,7 +63,7 @@ dependencies:
|
|
63
63
|
version: 3.1.1
|
64
64
|
type: :runtime
|
65
65
|
prerelease: false
|
66
|
-
version_requirements: *
|
66
|
+
version_requirements: *2153759240
|
67
67
|
description: ! ' Form builder for Haml
|
68
68
|
|
69
69
|
'
|
metadata.gz.sig
CHANGED
Binary file
|