padrino-helpers 0.16.0.pre4 → 0.16.0

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.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/README.rdoc +29 -29
  3. data/Rakefile +1 -1
  4. data/lib/padrino/rendering/erb_template.rb +7 -7
  5. data/lib/padrino/rendering/erubi_template.rb +4 -4
  6. data/lib/padrino/rendering/erubis_template.rb +4 -4
  7. data/lib/padrino/rendering/haml_template.rb +1 -1
  8. data/lib/padrino/rendering/hamlit_template.rb +4 -4
  9. data/lib/padrino/rendering/slim_template.rb +5 -5
  10. data/lib/padrino/rendering.rb +54 -45
  11. data/lib/padrino/safe_buffer.rb +31 -36
  12. data/lib/padrino-helpers/asset_tag_helpers.rb +48 -48
  13. data/lib/padrino-helpers/form_builder/abstract_form_builder.rb +74 -70
  14. data/lib/padrino-helpers/form_builder/standard_form_builder.rb +20 -20
  15. data/lib/padrino-helpers/form_helpers/errors.rb +14 -14
  16. data/lib/padrino-helpers/form_helpers/options.rb +25 -24
  17. data/lib/padrino-helpers/form_helpers/security.rb +5 -5
  18. data/lib/padrino-helpers/form_helpers.rb +133 -133
  19. data/lib/padrino-helpers/format_helpers.rb +61 -63
  20. data/lib/padrino-helpers/number_helpers.rb +82 -78
  21. data/lib/padrino-helpers/output_helpers/abstract_handler.rb +5 -3
  22. data/lib/padrino-helpers/output_helpers/erb_handler.rb +2 -2
  23. data/lib/padrino-helpers/output_helpers/haml_handler.rb +1 -1
  24. data/lib/padrino-helpers/output_helpers.rb +16 -17
  25. data/lib/padrino-helpers/render_helpers.rb +28 -27
  26. data/lib/padrino-helpers/tag_helpers.rb +62 -58
  27. data/lib/padrino-helpers/translation_helpers.rb +2 -2
  28. data/lib/padrino-helpers.rb +1 -2
  29. data/padrino-helpers.gemspec +17 -17
  30. data/test/fixtures/apps/render.rb +2 -2
  31. data/test/fixtures/markup_app/app.rb +9 -8
  32. data/test/fixtures/markup_app/views/button_to.erb +3 -3
  33. data/test/fixtures/markup_app/views/button_to.haml +2 -2
  34. data/test/fixtures/markup_app/views/button_to.slim +3 -3
  35. data/test/fixtures/markup_app/views/content_for.erb +4 -4
  36. data/test/fixtures/markup_app/views/content_for.haml +4 -4
  37. data/test/fixtures/markup_app/views/content_for.slim +2 -2
  38. data/test/fixtures/markup_app/views/content_tag.erb +3 -3
  39. data/test/fixtures/markup_app/views/content_tag.haml +3 -3
  40. data/test/fixtures/markup_app/views/content_tag.slim +3 -3
  41. data/test/fixtures/markup_app/views/fields_for.erb +2 -2
  42. data/test/fixtures/markup_app/views/fields_for.haml +2 -2
  43. data/test/fixtures/markup_app/views/fields_for.slim +2 -2
  44. data/test/fixtures/markup_app/views/form_for.erb +41 -41
  45. data/test/fixtures/markup_app/views/form_for.haml +41 -41
  46. data/test/fixtures/markup_app/views/form_for.slim +41 -42
  47. data/test/fixtures/markup_app/views/form_tag.erb +47 -47
  48. data/test/fixtures/markup_app/views/form_tag.haml +48 -48
  49. data/test/fixtures/markup_app/views/form_tag.slim +49 -49
  50. data/test/fixtures/markup_app/views/link_to.erb +2 -2
  51. data/test/fixtures/markup_app/views/link_to.haml +2 -2
  52. data/test/fixtures/markup_app/views/link_to.slim +2 -2
  53. data/test/fixtures/markup_app/views/meta_tag.erb +2 -2
  54. data/test/fixtures/markup_app/views/meta_tag.haml +2 -2
  55. data/test/fixtures/markup_app/views/meta_tag.slim +2 -2
  56. data/test/fixtures/markup_app/views/simple_partial.erb +1 -1
  57. data/test/fixtures/markup_app/views/simple_partial.haml +1 -1
  58. data/test/fixtures/markup_app/views/simple_partial.slim +1 -1
  59. data/test/fixtures/render_app/app.rb +13 -12
  60. data/test/fixtures/render_app/views/_unsafe.html.builder +1 -1
  61. data/test/fixtures/render_app/views/_unsafe_object.html.builder +1 -1
  62. data/test/fixtures/render_app/views/explicit_engine.haml +3 -3
  63. data/test/helper.rb +19 -19
  64. data/test/test_asset_tag_helpers.rb +133 -133
  65. data/test/test_form_builder.rb +629 -628
  66. data/test/test_form_helpers.rb +610 -610
  67. data/test/test_format_helpers.rb +66 -63
  68. data/test/test_helpers.rb +2 -2
  69. data/test/test_locale.rb +13 -11
  70. data/test/test_number_helpers.rb +65 -65
  71. data/test/test_output_helpers.rb +76 -76
  72. data/test/test_render_helpers.rb +101 -101
  73. data/test/test_rendering.rb +329 -326
  74. data/test/test_rendering_extensions.rb +4 -4
  75. data/test/test_tag_helpers.rb +55 -55
  76. metadata +6 -6
@@ -1,12 +1,12 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/helper')
1
+ require_relative 'helper'
2
2
 
3
- describe "Rendering Extensions" do
3
+ describe 'Rendering Extensions' do
4
4
  describe 'for haml' do
5
5
  it 'should render haml_tag correctly' do
6
- skip unless Padrino::Helpers::OutputHelpers.handlers[:haml].to_s == "Padrino::Helpers::OutputHelpers::HamlHandler"
6
+ skip unless Padrino::Helpers::OutputHelpers.handlers[:haml].to_s == 'Padrino::Helpers::OutputHelpers::HamlHandler'
7
7
 
8
8
  mock_app do
9
- get('/') { render :haml, '-haml_tag :div'}
9
+ get('/') { render :haml, '-haml_tag :div' }
10
10
  end
11
11
 
12
12
  get '/'
@@ -1,7 +1,7 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/helper')
2
- require File.expand_path(File.dirname(__FILE__) + '/fixtures/markup_app/app')
1
+ require_relative 'helper'
2
+ require_relative 'fixtures/markup_app/app'
3
3
 
4
- describe "TagHelpers" do
4
+ describe 'TagHelpers' do
5
5
  def app
6
6
  MarkupDemo
7
7
  end
@@ -12,106 +12,106 @@ describe "TagHelpers" do
12
12
  end
13
13
 
14
14
  it 'should support tags with no content with attributes' do
15
- actual_html = tag(:br, :style => 'clear:both', :class => 'yellow')
16
- assert_html_has_tag(actual_html, :br, :class => 'yellow', :style=>'clear:both')
15
+ actual_html = tag(:br, style: 'clear:both', class: 'yellow')
16
+ assert_html_has_tag(actual_html, :br, class: 'yellow', style: 'clear:both')
17
17
  end
18
18
 
19
19
  it 'should support selected attribute by using "selected" if true' do
20
- actual_html = tag(:option, :selected => true)
20
+ actual_html = tag(:option, selected: true)
21
21
  # fix nokogiri 1.6.8 on jRuby
22
22
  actual_html = content_tag(:select, actual_html)
23
- assert_html_has_tag(actual_html, 'option', :selected => 'selected')
23
+ assert_html_has_tag(actual_html, 'option', selected: 'selected')
24
24
  end
25
25
 
26
26
  it 'should support data attributes' do
27
- actual_html = tag(:a, :data => { :remote => true, :method => 'post'})
27
+ actual_html = tag(:a, data: { remote: true, method: 'post' })
28
28
  assert_html_has_tag(actual_html, :a, 'data-remote' => 'true', 'data-method' => 'post')
29
29
  end
30
30
 
31
31
  it 'should support nested attributes' do
32
- actual_html = tag(:div, :data => {:dojo => {:type => 'dijit.form.TextBox', :props => 'readOnly: true'}})
32
+ actual_html = tag(:div, data: { dojo: { type: 'dijit.form.TextBox', props: 'readOnly: true' } })
33
33
  assert_html_has_tag(actual_html, :div, 'data-dojo-type' => 'dijit.form.TextBox', 'data-dojo-props' => 'readOnly: true')
34
34
  end
35
35
 
36
36
  it 'should support open tags' do
37
- actual_html = tag(:p, { :class => 'demo' }, true)
38
- assert_equal "<p class=\"demo\">", actual_html
37
+ actual_html = tag(:p, { class: 'demo' }, true)
38
+ assert_equal '<p class="demo">', actual_html
39
39
  end
40
40
 
41
41
  it 'should escape html' do
42
- actual_html = tag(:br, :class => 'Example <foo> & "bar"')
43
- assert_equal "<br class=\"Example &lt;foo&gt; &amp; &quot;bar&quot;\" />", actual_html
42
+ actual_html = tag(:br, class: 'Example <foo> & "bar"')
43
+ assert_equal '<br class="Example &lt;foo&gt; &amp; &quot;bar&quot;" />', actual_html
44
44
  end
45
45
 
46
46
  it 'should allow array as attributes' do
47
- actual_html = tag(:p, :class => [:foo, :bar])
48
- assert_html_has_tag(actual_html, 'p.foo.bar')
47
+ actual_html = tag(:p, class: %i[foo bar])
48
+ assert_html_has_tag(actual_html, 'p.foo.bar')
49
49
  end
50
50
 
51
51
  it 'should allow array as nested attributes' do
52
- actual_html = tag(:p, :data => { :foo => [:bar, :baz] })
53
- assert_html_has_tag(actual_html, 'p', :'data-foo' => 'bar baz')
52
+ actual_html = tag(:p, data: { foo: %i[bar baz] })
53
+ assert_html_has_tag(actual_html, 'p', 'data-foo': 'bar baz')
54
54
  end
55
55
  end
56
56
 
57
57
  describe 'for #content_tag method' do
58
58
  it 'should support tags with content as parameter' do
59
- actual_html = content_tag(:p, "Demo", :class => 'large', :id => 'thing')
60
- assert_html_has_tag(actual_html, 'p.large#thing', :content => "Demo")
59
+ actual_html = content_tag(:p, 'Demo', class: 'large', id: 'thing')
60
+ assert_html_has_tag(actual_html, 'p.large#thing', content: 'Demo')
61
61
  end
62
62
 
63
63
  it 'should support tags with content as block' do
64
- actual_html = content_tag(:p, :class => 'large', :id => 'star') { "Demo" }
65
- assert_html_has_tag(actual_html, 'p.large#star', :content => "Demo")
64
+ actual_html = content_tag(:p, class: 'large', id: 'star') { 'Demo' }
65
+ assert_html_has_tag(actual_html, 'p.large#star', content: 'Demo')
66
66
  end
67
67
 
68
68
  it 'should escape non-html-safe content' do
69
- actual_html = content_tag(:p, :class => 'large', :id => 'star') { "<>" }
69
+ actual_html = content_tag(:p, class: 'large', id: 'star') { '<>' }
70
70
  assert_html_has_tag(actual_html, 'p.large#star')
71
71
  assert_match('&lt;&gt;', actual_html)
72
72
  end
73
73
 
74
74
  it 'should not escape html-safe content' do
75
- actual_html = content_tag(:p, :class => 'large', :id => 'star') { "<>" }
76
- assert_html_has_tag(actual_html, 'p.large#star', :content => "<>")
75
+ actual_html = content_tag(:p, class: 'large', id: 'star') { '<>' }
76
+ assert_html_has_tag(actual_html, 'p.large#star', content: '<>')
77
77
  end
78
78
 
79
79
  it 'should convert to a string if the content is not a string' do
80
80
  actual_html = content_tag(:p, 97)
81
- assert_html_has_tag(actual_html, 'p', :content => "97")
81
+ assert_html_has_tag(actual_html, 'p', content: '97')
82
82
  end
83
83
 
84
84
  it 'should support tags with erb' do
85
- get "/erb/content_tag"
86
- assert_response_has_tag :p, :content => "Test 1", :class => 'test', :id => 'test1'
87
- assert_response_has_tag :p, :content => "Test 2"
88
- assert_response_has_tag :p, :content => "Test 3"
89
- assert_response_has_tag :p, :content => "Test 4"
90
- assert_response_has_tag :p, :content => "one"
91
- assert_response_has_tag :p, :content => "two"
92
- assert_response_has_no_tag :p, :content => "failed"
85
+ get '/erb/content_tag'
86
+ assert_response_has_tag :p, content: 'Test 1', class: 'test', id: 'test1'
87
+ assert_response_has_tag :p, content: 'Test 2'
88
+ assert_response_has_tag :p, content: 'Test 3'
89
+ assert_response_has_tag :p, content: 'Test 4'
90
+ assert_response_has_tag :p, content: 'one'
91
+ assert_response_has_tag :p, content: 'two'
92
+ assert_response_has_no_tag :p, content: 'failed'
93
93
  end
94
94
 
95
95
  it 'should support tags with haml' do
96
- get "/haml/content_tag"
97
- assert_response_has_tag :p, :content => "Test 1", :class => 'test', :id => 'test1'
98
- assert_response_has_tag :p, :content => "Test 2"
99
- assert_response_has_tag :p, :content => "Test 3", :class => 'test', :id => 'test3'
100
- assert_response_has_tag :p, :content => "Test 4"
101
- assert_response_has_tag :p, :content => "one"
102
- assert_response_has_tag :p, :content => "two"
103
- assert_response_has_no_tag :p, :content => "failed"
96
+ get '/haml/content_tag'
97
+ assert_response_has_tag :p, content: 'Test 1', class: 'test', id: 'test1'
98
+ assert_response_has_tag :p, content: 'Test 2'
99
+ assert_response_has_tag :p, content: 'Test 3', class: 'test', id: 'test3'
100
+ assert_response_has_tag :p, content: 'Test 4'
101
+ assert_response_has_tag :p, content: 'one'
102
+ assert_response_has_tag :p, content: 'two'
103
+ assert_response_has_no_tag :p, content: 'failed'
104
104
  end
105
105
 
106
106
  it 'should support tags with slim' do
107
- get "/slim/content_tag"
108
- assert_response_has_tag :p, :content => "Test 1", :class => 'test', :id => 'test1'
109
- assert_response_has_tag :p, :content => "Test 2"
110
- assert_response_has_tag :p, :content => "Test 3", :class => 'test', :id => 'test3'
111
- assert_response_has_tag :p, :content => "Test 4"
112
- assert_response_has_tag :p, :content => "one"
113
- assert_response_has_tag :p, :content => "two"
114
- assert_response_has_no_tag :p, :content => "failed"
107
+ get '/slim/content_tag'
108
+ assert_response_has_tag :p, content: 'Test 1', class: 'test', id: 'test1'
109
+ assert_response_has_tag :p, content: 'Test 2'
110
+ assert_response_has_tag :p, content: 'Test 3', class: 'test', id: 'test3'
111
+ assert_response_has_tag :p, content: 'Test 4'
112
+ assert_response_has_tag :p, content: 'one'
113
+ assert_response_has_tag :p, content: 'two'
114
+ assert_response_has_no_tag :p, content: 'failed'
115
115
  end
116
116
  end
117
117
 
@@ -121,23 +121,23 @@ describe "TagHelpers" do
121
121
  end
122
122
 
123
123
  it 'should support field with type and options' do
124
- actual_html = input_tag(:text, :class => "first", :id => 'texter')
124
+ actual_html = input_tag(:text, class: 'first', id: 'texter')
125
125
  assert_html_has_tag(actual_html, 'input.first#texter[type=text]')
126
126
  end
127
127
 
128
128
  it 'should support checked attribute by using "checked" if true' do
129
- actual_html = input_tag(:checkbox, :checked => true)
130
- assert_html_has_tag(actual_html, 'input[type=checkbox]', :checked => 'checked')
129
+ actual_html = input_tag(:checkbox, checked: true)
130
+ assert_html_has_tag(actual_html, 'input[type=checkbox]', checked: 'checked')
131
131
  end
132
132
 
133
133
  it 'should remove checked attribute if false' do
134
- actual_html = input_tag(:checkbox, :checked => false)
134
+ actual_html = input_tag(:checkbox, checked: false)
135
135
  assert_html_has_no_tag(actual_html, 'input[type=checkbox][checked=false]')
136
136
  end
137
137
 
138
138
  it 'should support disabled attribute by using "disabled" if true' do
139
- actual_html = input_tag(:checkbox, :disabled => true)
140
- assert_html_has_tag(actual_html, 'input[type=checkbox]', :disabled => 'disabled')
139
+ actual_html = input_tag(:checkbox, disabled: true)
140
+ assert_html_has_tag(actual_html, 'input[type=checkbox]', disabled: 'disabled')
141
141
  end
142
142
  end
143
143
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: padrino-helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.0.pre4
4
+ version: 0.16.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Padrino Team
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2025-11-19 00:00:00.000000000 Z
14
+ date: 2025-12-02 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: padrino-support
@@ -19,14 +19,14 @@ dependencies:
19
19
  requirements:
20
20
  - - '='
21
21
  - !ruby/object:Gem::Version
22
- version: 0.16.0.pre4
22
+ version: 0.16.0
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - '='
28
28
  - !ruby/object:Gem::Version
29
- version: 0.16.0.pre4
29
+ version: 0.16.0
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: tilt
32
32
  requirement: !ruby/object:Gem::Requirement
@@ -247,9 +247,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
247
247
  version: '0'
248
248
  required_rubygems_version: !ruby/object:Gem::Requirement
249
249
  requirements:
250
- - - ">"
250
+ - - ">="
251
251
  - !ruby/object:Gem::Version
252
- version: 1.3.1
252
+ version: 1.3.6
253
253
  requirements: []
254
254
  rubygems_version: 3.4.19
255
255
  signing_key: