padrino-helpers 0.10.6.c → 0.10.6.d
Sign up to get free protection for your applications and to get access to all the features.
@@ -81,11 +81,11 @@ module Padrino
|
|
81
81
|
# @api public
|
82
82
|
def simple_format(text, options={})
|
83
83
|
t = options.delete(:tag) || :p
|
84
|
-
start_tag = tag(t, options)
|
84
|
+
start_tag = tag(t, options, true)
|
85
85
|
text = text.to_s.dup
|
86
86
|
text.gsub!(/\r\n?/, "\n") # \r\n and \r -> \n
|
87
87
|
text.gsub!(/\n\n+/, "</#{t}>\n\n#{start_tag}") # 2+ newline -> paragraph
|
88
|
-
text.gsub!(/([^\n]\n)(?=[^\n])/, '\1<br
|
88
|
+
text.gsub!(/([^\n]\n)(?=[^\n])/, '\1<br />') # 1 newline -> br
|
89
89
|
text.insert 0, start_tag
|
90
90
|
text << "</#{t}>"
|
91
91
|
end
|
@@ -138,16 +138,16 @@ module Padrino
|
|
138
138
|
#
|
139
139
|
# @example
|
140
140
|
# input_tag :text, :name => 'handle'
|
141
|
-
# # => <input type="test" name="handle"
|
141
|
+
# # => <input type="test" name="handle" />
|
142
142
|
#
|
143
143
|
# input_tag :password, :name => 'password', :size => 20
|
144
|
-
# # => <input type="password" name="password" size="20"
|
144
|
+
# # => <input type="password" name="password" size="20" />
|
145
145
|
#
|
146
146
|
# input_tag :text, :name => 'username', :required => true, :autofocus => true
|
147
|
-
# # => <input type="text" name="username" required autofocus
|
147
|
+
# # => <input type="text" name="username" required autofocus />
|
148
148
|
#
|
149
149
|
# input_tag :number, :name => 'credit_card', :autocomplete => :off
|
150
|
-
# # => <input type="number" autocomplete="off"
|
150
|
+
# # => <input type="number" autocomplete="off" />
|
151
151
|
#
|
152
152
|
# @api semipublic
|
153
153
|
def input_tag(type, options = {})
|
@@ -172,17 +172,17 @@ module Padrino
|
|
172
172
|
# # => <hr class="dotted">
|
173
173
|
#
|
174
174
|
# tag :input, :name => 'username', :type => :text
|
175
|
-
# # => <input name="username" type="text"
|
175
|
+
# # => <input name="username" type="text" />
|
176
176
|
#
|
177
177
|
# tag :img, :src => 'images/pony.jpg', :alt => 'My Little Pony'
|
178
|
-
# # => <img src="images/pony.jpg" alt="My Little Pony"
|
178
|
+
# # => <img src="images/pony.jpg" alt="My Little Pony" />
|
179
179
|
#
|
180
180
|
# tag :img, :src => 'sinatra.jpg, :data => { :nsfw => false, :geo => [34.087, -118.407] }
|
181
|
-
# # => <img src="sinatra.jpg" data-nsfw="false" data-geo="34.087 -118.407"
|
181
|
+
# # => <img src="sinatra.jpg" data-nsfw="false" data-geo="34.087 -118.407" />
|
182
182
|
#
|
183
183
|
# @api public
|
184
|
-
def tag(name, options = nil)
|
185
|
-
"<#{name}#{tag_options(options) if options}>"
|
184
|
+
def tag(name, options = nil, open = false)
|
185
|
+
"<#{name}#{tag_options(options) if options}#{open ? '>' : ' />'}"
|
186
186
|
end
|
187
187
|
|
188
188
|
private
|
@@ -176,6 +176,11 @@ describe "AssetTagHelpers" do
|
|
176
176
|
self.class.expects(:asset_stamp).returns(false)
|
177
177
|
assert_has_tag('img', :src => "/absolute/pic.gif") { image_tag('/absolute/pic.gif') }
|
178
178
|
end
|
179
|
+
|
180
|
+
should "have xhtml convention tag" do
|
181
|
+
self.class.expects(:asset_stamp).returns(false)
|
182
|
+
assert_equal image_tag('/absolute/pic.gif'), '<img src="/absolute/pic.gif" />'
|
183
|
+
end
|
179
184
|
end
|
180
185
|
|
181
186
|
context 'for #stylesheet_link_tag method' do
|
data/test/test_format_helpers.rb
CHANGED
@@ -15,7 +15,7 @@ describe "FormatHelpers" do
|
|
15
15
|
context 'for #simple_format method' do
|
16
16
|
should "format simple text into html format" do
|
17
17
|
actual_text = simple_format("Here is some basic text...\n...with a line break.")
|
18
|
-
assert_equal "<p>Here is some basic text...\n<br
|
18
|
+
assert_equal "<p>Here is some basic text...\n<br />...with a line break.</p>", actual_text
|
19
19
|
end
|
20
20
|
|
21
21
|
should "format more text into html format" do
|
@@ -31,7 +31,7 @@ describe "FormatHelpers" do
|
|
31
31
|
context 'wrapped in a custom tag' do
|
32
32
|
should "format simple text into html format" do
|
33
33
|
actual_text = simple_format("Here is some basic text...\n...with a line break.", :tag => :div)
|
34
|
-
assert_equal "<div>Here is some basic text...\n<br
|
34
|
+
assert_equal "<div>Here is some basic text...\n<br />...with a line break.</div>", actual_text
|
35
35
|
end
|
36
36
|
|
37
37
|
should "format more text into html format" do
|
data/test/test_tag_helpers.rb
CHANGED
@@ -7,6 +7,15 @@ describe "TagHelpers" do
|
|
7
7
|
end
|
8
8
|
|
9
9
|
context 'for #tag method' do
|
10
|
+
should("support tags with no content no attributes") do
|
11
|
+
assert_has_tag(:br) { tag(:br) }
|
12
|
+
end
|
13
|
+
|
14
|
+
should("support tags with no content with attributes") do
|
15
|
+
actual_html = tag(:br, :style => 'clear:both', :class => 'yellow')
|
16
|
+
assert_has_tag(:br, :class => 'yellow', :style=>'clear:both') { actual_html }
|
17
|
+
end
|
18
|
+
|
10
19
|
should "support selected attribute by using 'selected' if true" do
|
11
20
|
actual_html = tag(:option, :selected => true)
|
12
21
|
assert_has_tag('option', :selected => 'selected') { actual_html }
|
@@ -17,9 +26,14 @@ describe "TagHelpers" do
|
|
17
26
|
assert_has_tag(:a, 'data-remote' => 'true', 'data-method' => 'post') { actual_html }
|
18
27
|
end
|
19
28
|
|
29
|
+
should "support open tags" do
|
30
|
+
actual_html = tag(:p, { :class => 'demo' }, true)
|
31
|
+
assert_equal "<p class=\"demo\">", actual_html
|
32
|
+
end
|
33
|
+
|
20
34
|
should "escape html" do
|
21
35
|
actual_html = tag(:br, :class => 'Example "bar"')
|
22
|
-
assert_equal "<br class=\"Example "bar"\"
|
36
|
+
assert_equal "<br class=\"Example "bar"\" />", actual_html
|
23
37
|
end
|
24
38
|
end
|
25
39
|
|
metadata
CHANGED
@@ -1,16 +1,10 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: padrino-helpers
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.10.6.d
|
5
5
|
prerelease: 7
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 10
|
9
|
-
- 6
|
10
|
-
- c
|
11
|
-
version: 0.10.6.c
|
12
6
|
platform: ruby
|
13
|
-
authors:
|
7
|
+
authors:
|
14
8
|
- Padrino Team
|
15
9
|
- Nathan Esquenazi
|
16
10
|
- Davide D'Agostino
|
@@ -18,51 +12,38 @@ authors:
|
|
18
12
|
autorequire:
|
19
13
|
bindir: bin
|
20
14
|
cert_chain: []
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
dependencies:
|
25
|
-
- !ruby/object:Gem::Dependency
|
15
|
+
date: 2012-02-23 00:00:00.000000000 Z
|
16
|
+
dependencies:
|
17
|
+
- !ruby/object:Gem::Dependency
|
26
18
|
name: padrino-core
|
27
|
-
|
28
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
19
|
+
requirement: &70111273349200 !ruby/object:Gem::Requirement
|
29
20
|
none: false
|
30
|
-
requirements:
|
31
|
-
- -
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
|
34
|
-
segments:
|
35
|
-
- 0
|
36
|
-
- 10
|
37
|
-
- 6
|
38
|
-
- c
|
39
|
-
version: 0.10.6.c
|
21
|
+
requirements:
|
22
|
+
- - =
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: 0.10.6.d
|
40
25
|
type: :runtime
|
41
|
-
version_requirements: *id001
|
42
|
-
- !ruby/object:Gem::Dependency
|
43
|
-
name: i18n
|
44
26
|
prerelease: false
|
45
|
-
|
27
|
+
version_requirements: *70111273349200
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: i18n
|
30
|
+
requirement: &70111273347840 !ruby/object:Gem::Requirement
|
46
31
|
none: false
|
47
|
-
requirements:
|
32
|
+
requirements:
|
48
33
|
- - ~>
|
49
|
-
- !ruby/object:Gem::Version
|
50
|
-
|
51
|
-
segments:
|
52
|
-
- 0
|
53
|
-
- 6
|
54
|
-
version: "0.6"
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: '0.6'
|
55
36
|
type: :runtime
|
56
|
-
|
57
|
-
|
37
|
+
prerelease: false
|
38
|
+
version_requirements: *70111273347840
|
39
|
+
description: Tag helpers, asset helpers, form helpers, form builders and many more
|
40
|
+
helpers for padrino
|
58
41
|
email: padrinorb@gmail.com
|
59
42
|
executables: []
|
60
|
-
|
61
43
|
extensions: []
|
62
|
-
|
63
|
-
extra_rdoc_files:
|
44
|
+
extra_rdoc_files:
|
64
45
|
- README.rdoc
|
65
|
-
files:
|
46
|
+
files:
|
66
47
|
- .document
|
67
48
|
- .gitignore
|
68
49
|
- .yardopts
|
@@ -162,43 +143,32 @@ files:
|
|
162
143
|
- test/test_output_helpers.rb
|
163
144
|
- test/test_render_helpers.rb
|
164
145
|
- test/test_tag_helpers.rb
|
165
|
-
has_rdoc: true
|
166
146
|
homepage: http://www.padrinorb.com
|
167
147
|
licenses: []
|
168
|
-
|
169
148
|
post_install_message:
|
170
|
-
rdoc_options:
|
149
|
+
rdoc_options:
|
171
150
|
- --charset=UTF-8
|
172
|
-
require_paths:
|
151
|
+
require_paths:
|
173
152
|
- lib
|
174
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
153
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
175
154
|
none: false
|
176
|
-
requirements:
|
177
|
-
- -
|
178
|
-
- !ruby/object:Gem::Version
|
179
|
-
|
180
|
-
|
181
|
-
- 0
|
182
|
-
version: "0"
|
183
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
155
|
+
requirements:
|
156
|
+
- - ! '>='
|
157
|
+
- !ruby/object:Gem::Version
|
158
|
+
version: '0'
|
159
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
184
160
|
none: false
|
185
|
-
requirements:
|
186
|
-
- -
|
187
|
-
- !ruby/object:Gem::Version
|
188
|
-
hash: 25
|
189
|
-
segments:
|
190
|
-
- 1
|
191
|
-
- 3
|
192
|
-
- 1
|
161
|
+
requirements:
|
162
|
+
- - ! '>'
|
163
|
+
- !ruby/object:Gem::Version
|
193
164
|
version: 1.3.1
|
194
165
|
requirements: []
|
195
|
-
|
196
166
|
rubyforge_project: padrino-helpers
|
197
|
-
rubygems_version: 1.
|
167
|
+
rubygems_version: 1.8.17
|
198
168
|
signing_key:
|
199
169
|
specification_version: 3
|
200
170
|
summary: Helpers for padrino
|
201
|
-
test_files:
|
171
|
+
test_files:
|
202
172
|
- test/fixtures/markup_app/app.rb
|
203
173
|
- test/fixtures/markup_app/views/capture_concat.erb
|
204
174
|
- test/fixtures/markup_app/views/capture_concat.haml
|
@@ -257,3 +227,4 @@ test_files:
|
|
257
227
|
- test/test_output_helpers.rb
|
258
228
|
- test/test_render_helpers.rb
|
259
229
|
- test/test_tag_helpers.rb
|
230
|
+
has_rdoc:
|