actionview 4.2.11.3 → 5.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of actionview might be problematic. Click here for more details.

Files changed (65) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +136 -255
  3. data/MIT-LICENSE +1 -1
  4. data/README.rdoc +2 -3
  5. data/lib/action_view.rb +1 -1
  6. data/lib/action_view/base.rb +14 -2
  7. data/lib/action_view/dependency_tracker.rb +46 -15
  8. data/lib/action_view/digestor.rb +13 -9
  9. data/lib/action_view/flows.rb +1 -1
  10. data/lib/action_view/gem_version.rb +4 -4
  11. data/lib/action_view/helpers/asset_tag_helper.rb +15 -5
  12. data/lib/action_view/helpers/asset_url_helper.rb +51 -12
  13. data/lib/action_view/helpers/atom_feed_helper.rb +5 -4
  14. data/lib/action_view/helpers/cache_helper.rb +75 -20
  15. data/lib/action_view/helpers/capture_helper.rb +3 -2
  16. data/lib/action_view/helpers/controller_helper.rb +1 -0
  17. data/lib/action_view/helpers/date_helper.rb +39 -10
  18. data/lib/action_view/helpers/debug_helper.rb +1 -1
  19. data/lib/action_view/helpers/form_helper.rb +81 -35
  20. data/lib/action_view/helpers/form_options_helper.rb +74 -35
  21. data/lib/action_view/helpers/form_tag_helper.rb +46 -19
  22. data/lib/action_view/helpers/javascript_helper.rb +4 -4
  23. data/lib/action_view/helpers/number_helper.rb +10 -12
  24. data/lib/action_view/helpers/record_tag_helper.rb +12 -99
  25. data/lib/action_view/helpers/rendering_helper.rb +2 -2
  26. data/lib/action_view/helpers/sanitize_helper.rb +1 -2
  27. data/lib/action_view/helpers/tag_helper.rb +20 -13
  28. data/lib/action_view/helpers/tags/base.rb +33 -28
  29. data/lib/action_view/helpers/tags/collection_check_boxes.rb +2 -30
  30. data/lib/action_view/helpers/tags/collection_helpers.rb +28 -0
  31. data/lib/action_view/helpers/tags/collection_radio_buttons.rb +1 -9
  32. data/lib/action_view/helpers/tags/file_field.rb +15 -0
  33. data/lib/action_view/helpers/tags/label.rb +1 -1
  34. data/lib/action_view/helpers/tags/placeholderable.rb +1 -1
  35. data/lib/action_view/helpers/tags/search_field.rb +12 -9
  36. data/lib/action_view/helpers/tags/text_field.rb +0 -1
  37. data/lib/action_view/helpers/tags/translator.rb +1 -1
  38. data/lib/action_view/helpers/text_helper.rb +25 -9
  39. data/lib/action_view/helpers/translation_helper.rb +56 -26
  40. data/lib/action_view/helpers/url_helper.rb +40 -65
  41. data/lib/action_view/layouts.rb +11 -10
  42. data/lib/action_view/lookup_context.rb +14 -40
  43. data/lib/action_view/model_naming.rb +1 -1
  44. data/lib/action_view/path_set.rb +15 -18
  45. data/lib/action_view/railtie.rb +20 -3
  46. data/lib/action_view/record_identifier.rb +44 -19
  47. data/lib/action_view/renderer/abstract_renderer.rb +1 -1
  48. data/lib/action_view/renderer/partial_renderer.rb +27 -26
  49. data/lib/action_view/renderer/partial_renderer/collection_caching.rb +70 -0
  50. data/lib/action_view/renderer/renderer.rb +2 -6
  51. data/lib/action_view/renderer/streaming_template_renderer.rb +1 -1
  52. data/lib/action_view/renderer/template_renderer.rb +12 -11
  53. data/lib/action_view/rendering.rb +8 -5
  54. data/lib/action_view/routing_url_for.rb +18 -6
  55. data/lib/action_view/template.rb +50 -13
  56. data/lib/action_view/template/error.rb +14 -7
  57. data/lib/action_view/template/handlers.rb +3 -3
  58. data/lib/action_view/template/handlers/erb.rb +25 -0
  59. data/lib/action_view/template/handlers/raw.rb +1 -1
  60. data/lib/action_view/template/resolver.rb +36 -58
  61. data/lib/action_view/template/types.rb +1 -1
  62. data/lib/action_view/test_case.rb +13 -8
  63. data/lib/action_view/testing/resolvers.rb +3 -4
  64. data/lib/action_view/view_paths.rb +6 -22
  65. metadata +17 -14
@@ -18,10 +18,10 @@ module ActionView
18
18
  #
19
19
  # could become:
20
20
  #
21
- # <select name="post[category]">
22
- # <option></option>
23
- # <option>joke</option>
24
- # <option>poem</option>
21
+ # <select name="post[category]" id="post_category">
22
+ # <option value=""></option>
23
+ # <option value="joke">joke</option>
24
+ # <option value="poem">poem</option>
25
25
  # </select>
26
26
  #
27
27
  # Another common case is a select tag for a <tt>belongs_to</tt>-associated object.
@@ -32,11 +32,11 @@ module ActionView
32
32
  #
33
33
  # could become:
34
34
  #
35
- # <select name="post[person_id]">
35
+ # <select name="post[person_id]" id="post_person_id">
36
36
  # <option value="">None</option>
37
37
  # <option value="1">David</option>
38
- # <option value="2" selected="selected">Sam</option>
39
- # <option value="3">Tobias</option>
38
+ # <option value="2" selected="selected">Eileen</option>
39
+ # <option value="3">Rafael</option>
40
40
  # </select>
41
41
  #
42
42
  # * <tt>:prompt</tt> - set to true or a prompt string. When the select element doesn't have a value yet, this prepends an option with a generic prompt -- "Please select" -- or the given prompt string.
@@ -45,11 +45,11 @@ module ActionView
45
45
  #
46
46
  # could become:
47
47
  #
48
- # <select name="post[person_id]">
48
+ # <select name="post[person_id]" id="post_person_id">
49
49
  # <option value="">Select Person</option>
50
50
  # <option value="1">David</option>
51
- # <option value="2">Sam</option>
52
- # <option value="3">Tobias</option>
51
+ # <option value="2">Eileen</option>
52
+ # <option value="3">Rafael</option>
53
53
  # </select>
54
54
  #
55
55
  # * <tt>:index</tt> - like the other form helpers, +select+ can accept an <tt>:index</tt> option to manually set the ID used in the resulting output. Unlike other helpers, +select+ expects this
@@ -71,19 +71,19 @@ module ActionView
71
71
  #
72
72
  # could become:
73
73
  #
74
- # <select name="post[category]">
75
- # <option></option>
76
- # <option>joke</option>
77
- # <option>poem</option>
78
- # <option disabled="disabled">restricted</option>
74
+ # <select name="post[category]" id="post_category">
75
+ # <option value=""></option>
76
+ # <option value="joke">joke</option>
77
+ # <option value="poem">poem</option>
78
+ # <option disabled="disabled" value="restricted">restricted</option>
79
79
  # </select>
80
80
  #
81
81
  # When used with the <tt>collection_select</tt> helper, <tt>:disabled</tt> can also be a Proc that identifies those options that should be disabled.
82
82
  #
83
- # collection_select(:post, :category_id, Category.all, :id, :name, {disabled: lambda{|category| category.archived? }})
83
+ # collection_select(:post, :category_id, Category.all, :id, :name, {disabled: -> (category) { category.archived? }})
84
84
  #
85
85
  # If the categories "2008 stuff" and "Christmas" return true when the method <tt>archived?</tt> is called, this would return:
86
- # <select name="post[category_id]">
86
+ # <select name="post[category_id]" id="post_category_id">
87
87
  # <option value="1" disabled="disabled">2008 stuff</option>
88
88
  # <option value="2" disabled="disabled">Christmas</option>
89
89
  # <option value="3">Jokes</option>
@@ -109,11 +109,11 @@ module ActionView
109
109
  #
110
110
  # would become:
111
111
  #
112
- # <select name="post[person_id]">
112
+ # <select name="post[person_id]" id="post_person_id">
113
113
  # <option value=""></option>
114
114
  # <option value="1" selected="selected">David</option>
115
- # <option value="2">Sam</option>
116
- # <option value="3">Tobias</option>
115
+ # <option value="2">Eileen</option>
116
+ # <option value="3">Rafael</option>
117
117
  # </select>
118
118
  #
119
119
  # assuming the associated person has ID 1.
@@ -192,7 +192,7 @@ module ActionView
192
192
  # collection_select(:post, :author_id, Author.all, :id, :name_with_initial, prompt: true)
193
193
  #
194
194
  # If <tt>@post.author_id</tt> is already <tt>1</tt>, this would return:
195
- # <select name="post[author_id]">
195
+ # <select name="post[author_id]" id="post_author_id">
196
196
  # <option value="">Please select</option>
197
197
  # <option value="1" selected="selected">D. Heinemeier Hansson</option>
198
198
  # <option value="2">D. Thomas</option>
@@ -243,7 +243,7 @@ module ActionView
243
243
  #
244
244
  # Possible output:
245
245
  #
246
- # <select name="city[country_id]">
246
+ # <select name="city[country_id]" id="city_country_id">
247
247
  # <optgroup label="Africa">
248
248
  # <option value="1">South Africa</option>
249
249
  # <option value="3">Somalia</option>
@@ -302,17 +302,17 @@ module ActionView
302
302
  # # => <option value="DKK">Kroner</option>
303
303
  #
304
304
  # options_for_select([ "VISA", "MasterCard" ], "MasterCard")
305
- # # => <option>VISA</option>
306
- # # => <option selected="selected">MasterCard</option>
305
+ # # => <option value="VISA">VISA</option>
306
+ # # => <option selected="selected" value="MasterCard">MasterCard</option>
307
307
  #
308
308
  # options_for_select({ "Basic" => "$20", "Plus" => "$40" }, "$40")
309
309
  # # => <option value="$20">Basic</option>
310
310
  # # => <option value="$40" selected="selected">Plus</option>
311
311
  #
312
312
  # options_for_select([ "VISA", "MasterCard", "Discover" ], ["VISA", "Discover"])
313
- # # => <option selected="selected">VISA</option>
314
- # # => <option>MasterCard</option>
315
- # # => <option selected="selected">Discover</option>
313
+ # # => <option selected="selected" value="VISA">VISA</option>
314
+ # # => <option value="MasterCard">MasterCard</option>
315
+ # # => <option selected="selected" value="Discover">Discover</option>
316
316
  #
317
317
  # You can optionally provide HTML attributes as the last element of the array.
318
318
  #
@@ -351,12 +351,12 @@ module ActionView
351
351
  return container if String === container
352
352
 
353
353
  selected, disabled = extract_selected_and_disabled(selected).map do |r|
354
- Array(r).map { |item| item.to_s }
354
+ Array(r).map(&:to_s)
355
355
  end
356
356
 
357
357
  container.map do |element|
358
358
  html_attributes = option_html_attributes(element)
359
- text, value = option_text_and_value(element).map { |item| item.to_s }
359
+ text, value = option_text_and_value(element).map(&:to_s)
360
360
 
361
361
  html_attributes[:selected] ||= option_value_selected?(value, selected)
362
362
  html_attributes[:disabled] ||= disabled && option_value_selected?(value, disabled)
@@ -456,7 +456,7 @@ module ActionView
456
456
  option_tags = options_from_collection_for_select(
457
457
  group.send(group_method), option_key_method, option_value_method, selected_key)
458
458
 
459
- content_tag(:optgroup, option_tags, label: group.send(group_label_method))
459
+ content_tag("optgroup".freeze, option_tags, label: group.send(group_label_method))
460
460
  end.join.html_safe
461
461
  end
462
462
 
@@ -528,7 +528,7 @@ module ActionView
528
528
  body = "".html_safe
529
529
 
530
530
  if prompt
531
- body.safe_concat content_tag(:option, prompt_text(prompt), value: "")
531
+ body.safe_concat content_tag("option".freeze, prompt_text(prompt), value: "")
532
532
  end
533
533
 
534
534
  grouped_options.each do |container|
@@ -541,14 +541,14 @@ module ActionView
541
541
  end
542
542
 
543
543
  html_attributes = { label: label }.merge!(html_attributes)
544
- body.safe_concat content_tag(:optgroup, options_for_select(container, selected_key), html_attributes)
544
+ body.safe_concat content_tag("optgroup".freeze, options_for_select(container, selected_key), html_attributes)
545
545
  end
546
546
 
547
547
  body
548
548
  end
549
549
 
550
550
  # Returns a string of option tags for pretty much any time zone in the
551
- # world. Supply a ActiveSupport::TimeZone name as +selected+ to have it
551
+ # world. Supply an ActiveSupport::TimeZone name as +selected+ to have it
552
552
  # marked as the selected option tag. You can also supply an array of
553
553
  # ActiveSupport::TimeZone objects as +priority_zones+, so that they will
554
554
  # be listed above the rest of the (long) list. (You can use
@@ -556,7 +556,7 @@ module ActionView
556
556
  # of the US time zones, or a Regexp to select the zones of your choice)
557
557
  #
558
558
  # The +selected+ parameter must be either +nil+, or a string that names
559
- # a ActiveSupport::TimeZone.
559
+ # an ActiveSupport::TimeZone.
560
560
  #
561
561
  # By default, +model+ is the ActiveSupport::TimeZone constant (which can
562
562
  # be obtained in Active Record as a value object). The only requirement
@@ -577,7 +577,7 @@ module ActionView
577
577
  end
578
578
 
579
579
  zone_options.safe_concat options_for_select(convert_zones[priority_zones], selected)
580
- zone_options.safe_concat content_tag(:option, '-------------', value: '', disabled: true)
580
+ zone_options.safe_concat content_tag("option".freeze, '-------------', value: '', disabled: true)
581
581
  zone_options.safe_concat "\n"
582
582
 
583
583
  zones = zones - priority_zones
@@ -644,6 +644,24 @@ module ActionView
644
644
  # collection_radio_buttons(:post, :author_id, Author.all, :id, :name_with_initial) do |b|
645
645
  # b.label(:"data-value" => b.value) { b.radio_button + b.text }
646
646
  # end
647
+ #
648
+ # ==== Gotcha
649
+ #
650
+ # The HTML specification says when nothing is select on a collection of radio buttons
651
+ # web browsers do not send any value to server.
652
+ # Unfortunately this introduces a gotcha:
653
+ # if a +User+ model has a +category_id+ field, and in the form none category is selected no +category_id+ parameter is sent. So,
654
+ # any strong parameters idiom like
655
+ #
656
+ # params.require(:user).permit(...)
657
+ #
658
+ # will raise an error since no +{user: ...}+ will be present.
659
+ #
660
+ # To prevent this the helper generates an auxiliary hidden field before
661
+ # every collection of radio buttons. The hidden field has the same name as collection radio button and blank value.
662
+ #
663
+ # In case if you don't want the helper to generate this hidden field you can specify
664
+ # <tt>include_hidden: false</tt> option.
647
665
  def collection_radio_buttons(object, method, collection, value_method, text_method, options = {}, html_options = {}, &block)
648
666
  Tags::CollectionRadioButtons.new(object, method, self, collection, value_method, text_method, options, html_options).render(&block)
649
667
  end
@@ -707,6 +725,27 @@ module ActionView
707
725
  # collection_check_boxes(:post, :author_ids, Author.all, :id, :name_with_initial) do |b|
708
726
  # b.label(:"data-value" => b.value) { b.check_box + b.text }
709
727
  # end
728
+ #
729
+ # ==== Gotcha
730
+ #
731
+ # When no selection is made for a collection of checkboxes most
732
+ # web browsers will not send any value.
733
+ #
734
+ # For example, if we have a +User+ model with +category_ids+ field and we
735
+ # have the following code in our update action:
736
+ #
737
+ # @user.update(params[:user])
738
+ #
739
+ # If no +category_ids+ are selected then we can safely assume this field
740
+ # will not be updated.
741
+ #
742
+ # This is possible thanks to a hidden field generated by the helper method
743
+ # for every collection of checkboxes.
744
+ # This hidden field is given the same field name as the checkboxes with a
745
+ # blank value.
746
+ #
747
+ # In the rare case you don't want this hidden field, you can pass the
748
+ # <tt>include_hidden: false</tt> option to the helper method.
710
749
  def collection_check_boxes(object, method, collection, value_method, text_method, options = {}, html_options = {}, &block)
711
750
  Tags::CollectionCheckBoxes.new(object, method, self, collection, value_method, text_method, options, html_options).render(&block)
712
751
  end
@@ -20,7 +20,7 @@ module ActionView
20
20
  mattr_accessor :embed_authenticity_token_in_remote_forms
21
21
  self.embed_authenticity_token_in_remote_forms = false
22
22
 
23
- # Starts a form tag that points the action to an url configured with <tt>url_for_options</tt> just like
23
+ # Starts a form tag that points the action to a url configured with <tt>url_for_options</tt> just like
24
24
  # ActionController::Base#url_for. The method for the form defaults to POST.
25
25
  #
26
26
  # ==== Options
@@ -80,7 +80,7 @@ module ActionView
80
80
  # associated records. <tt>option_tags</tt> is a string containing the option tags for the select box.
81
81
  #
82
82
  # ==== Options
83
- # * <tt>:multiple</tt> - If set to true the selection will allow multiple choices.
83
+ # * <tt>:multiple</tt> - If set to true, the selection will allow multiple choices.
84
84
  # * <tt>:disabled</tt> - If set to true, the user will not be able to use this input.
85
85
  # * <tt>:include_blank</tt> - If set to true, an empty option will be created. If set to a string, the string will be used as the option's content and the value will be empty.
86
86
  # * <tt>:prompt</tt> - Create a prompt option with blank value and the text asking user to select something.
@@ -140,15 +140,15 @@ module ActionView
140
140
  end
141
141
 
142
142
  if include_blank
143
- option_tags = content_tag(:option, include_blank, value: '').safe_concat(option_tags)
143
+ option_tags = content_tag("option".freeze, include_blank, value: '').safe_concat(option_tags)
144
144
  end
145
145
  end
146
146
 
147
147
  if prompt = options.delete(:prompt)
148
- option_tags = content_tag(:option, prompt, value: '').safe_concat(option_tags)
148
+ option_tags = content_tag("option".freeze, prompt, value: '').safe_concat(option_tags)
149
149
  end
150
150
 
151
- content_tag :select, option_tags, { "name" => html_name, "id" => sanitize_to_id(name) }.update(options.stringify_keys)
151
+ content_tag "select".freeze, option_tags, { "name" => html_name, "id" => sanitize_to_id(name) }.update(options.stringify_keys)
152
152
  end
153
153
 
154
154
  # Creates a standard text field; use these text fields to input smaller chunks of text like a username
@@ -414,42 +414,57 @@ module ActionView
414
414
  # the form is processed normally, otherwise no action is taken.
415
415
  # * <tt>:disable_with</tt> - Value of this parameter will be used as the value for a
416
416
  # disabled version of the submit button when the form is submitted. This feature is
417
- # provided by the unobtrusive JavaScript driver.
417
+ # provided by the unobtrusive JavaScript driver. To disable this feature for a single submit tag
418
+ # pass <tt>:data => { disable_with: false }</tt> Defaults to value attribute.
418
419
  #
419
420
  # ==== Examples
420
421
  # submit_tag
421
- # # => <input name="commit" type="submit" value="Save changes" />
422
+ # # => <input name="commit" data-disable-with="Save changes" type="submit" value="Save changes" />
422
423
  #
423
424
  # submit_tag "Edit this article"
424
- # # => <input name="commit" type="submit" value="Edit this article" />
425
+ # # => <input name="commit" data-disable-with="Edit this article" type="submit" value="Edit this article" />
425
426
  #
426
427
  # submit_tag "Save edits", disabled: true
427
- # # => <input disabled="disabled" name="commit" type="submit" value="Save edits" />
428
+ # # => <input disabled="disabled" name="commit" data-disable-with="Save edits" type="submit" value="Save edits" />
428
429
  #
429
- # submit_tag "Complete sale", data: { disable_with: "Please wait..." }
430
- # # => <input name="commit" data-disable-with="Please wait..." type="submit" value="Complete sale" />
430
+ # submit_tag "Complete sale", data: { disable_with: "Submitting..." }
431
+ # # => <input name="commit" data-disable-with="Submitting..." type="submit" value="Complete sale" />
431
432
  #
432
433
  # submit_tag nil, class: "form_submit"
433
434
  # # => <input class="form_submit" name="commit" type="submit" />
434
435
  #
435
436
  # submit_tag "Edit", class: "edit_button"
436
- # # => <input class="edit_button" name="commit" type="submit" value="Edit" />
437
+ # # => <input class="edit_button" data-disable-with="Edit" name="commit" type="submit" value="Edit" />
437
438
  #
438
439
  # submit_tag "Save", data: { confirm: "Are you sure?" }
439
- # # => <input name='commit' type='submit' value='Save' data-confirm="Are you sure?" />
440
+ # # => <input name='commit' type='submit' value='Save' data-disable-with="Save" data-confirm="Are you sure?" />
440
441
  #
441
442
  def submit_tag(value = "Save changes", options = {})
442
443
  options = options.stringify_keys
444
+ tag_options = { "type" => "submit", "name" => "commit", "value" => value }.update(options)
445
+
446
+ if ActionView::Base.automatically_disable_submit_tag
447
+ unless tag_options["data-disable-with"] == false || (tag_options["data"] && tag_options["data"][:disable_with] == false)
448
+ disable_with_text = tag_options["data-disable-with"]
449
+ disable_with_text ||= tag_options["data"][:disable_with] if tag_options["data"]
450
+ disable_with_text ||= value.clone
451
+ tag_options.deep_merge!("data" => { "disable_with" => disable_with_text })
452
+ else
453
+ tag_options["data"].delete(:disable_with) if tag_options["data"]
454
+ end
455
+ tag_options.delete("data-disable-with")
456
+ end
443
457
 
444
- tag :input, { "type" => "submit", "name" => "commit", "value" => value }.update(options)
458
+ tag :input, tag_options
445
459
  end
446
460
 
447
461
  # Creates a button element that defines a <tt>submit</tt> button,
448
462
  # <tt>reset</tt>button or a generic button which can be used in
449
463
  # JavaScript, for example. You can use the button tag as a regular
450
464
  # submit tag but it isn't supported in legacy browsers. However,
451
- # the button tag allows richer labels such as images and emphasis,
452
- # so this helper will also accept a block.
465
+ # the button tag does allow for richer labels such as images and emphasis,
466
+ # so this helper will also accept a block. By default, it will create
467
+ # a button tag with type `submit`, if type is not given.
453
468
  #
454
469
  # ==== Options
455
470
  # * <tt>:data</tt> - This option can be used to add custom data attributes.
@@ -472,6 +487,15 @@ module ActionView
472
487
  # button_tag
473
488
  # # => <button name="button" type="submit">Button</button>
474
489
  #
490
+ # button_tag 'Reset', type: 'reset'
491
+ # # => <button name="button" type="reset">Reset</button>
492
+ #
493
+ # button_tag 'Button', type: 'button'
494
+ # # => <button name="button" type="button">Button</button>
495
+ #
496
+ # button_tag 'Reset', type: 'reset', disabled: true
497
+ # # => <button name="button" type="reset" disabled="disabled">Reset</button>
498
+ #
475
499
  # button_tag(type: 'button') do
476
500
  # content_tag(:strong, 'Ask me!')
477
501
  # end
@@ -479,6 +503,9 @@ module ActionView
479
503
  # # <strong>Ask me!</strong>
480
504
  # # </button>
481
505
  #
506
+ # button_tag "Save", data: { confirm: "Are you sure?" }
507
+ # # => <button name="button" type="submit" data-confirm="Are you sure?">Save</button>
508
+ #
482
509
  # button_tag "Checkout", data: { disable_with: "Please wait..." }
483
510
  # # => <button data-disable-with="Please wait..." name="button" type="submit">Checkout</button>
484
511
  #
@@ -555,7 +582,7 @@ module ActionView
555
582
  # # => <fieldset class="format"><p><input id="name" name="name" type="text" /></p></fieldset>
556
583
  def field_set_tag(legend = nil, options = nil, &block)
557
584
  output = tag(:fieldset, options, true)
558
- output.safe_concat(content_tag(:legend, legend)) unless legend.blank?
585
+ output.safe_concat(content_tag("legend".freeze, legend)) unless legend.blank?
559
586
  output.concat(capture(&block)) if block_given?
560
587
  output.safe_concat("</fieldset>")
561
588
  end
@@ -776,10 +803,10 @@ module ActionView
776
803
  # # => <input id="quantity" name="quantity" min="1" max="9" type="number" />
777
804
  #
778
805
  # number_field_tag 'quantity', nil, min: 1, max: 10
779
- # # => <input id="quantity" name="quantity" min="1" max="9" type="number" />
806
+ # # => <input id="quantity" name="quantity" min="1" max="10" type="number" />
780
807
  #
781
808
  # number_field_tag 'quantity', nil, min: 1, max: 10, step: 2
782
- # # => <input id="quantity" name="quantity" min="1" max="9" step="2" type="number" />
809
+ # # => <input id="quantity" name="quantity" min="1" max="10" step="2" type="number" />
783
810
  #
784
811
  # number_field_tag 'quantity', '1', class: 'special_input', disabled: true
785
812
  # # => <input disabled="disabled" class="special_input" id="quantity" name="quantity" type="number" value="1" />
@@ -21,7 +21,7 @@ module ActionView
21
21
  # Also available through the alias j(). This is particularly helpful in JavaScript
22
22
  # responses, like:
23
23
  #
24
- # $('some_element').replaceWith('<%=j render 'some/element_template' %>');
24
+ # $('some_element').replaceWith('<%= j render 'some/element_template' %>');
25
25
  def escape_javascript(javascript)
26
26
  if javascript
27
27
  result = javascript.gsub(/(\\|<\/|\r\n|\342\200\250|\342\200\251|[\n\r"'])/u) {|match| JS_ESCAPE_MAP[match] }
@@ -47,8 +47,8 @@ module ActionView
47
47
  # tag.
48
48
  #
49
49
  # javascript_tag "alert('All is good')", defer: 'defer'
50
- #
51
- # Returns:
50
+ #
51
+ # Returns:
52
52
  # <script defer="defer">
53
53
  # //<![CDATA[
54
54
  # alert('All is good')
@@ -70,7 +70,7 @@ module ActionView
70
70
  content_or_options_with_block
71
71
  end
72
72
 
73
- content_tag(:script, javascript_cdata_section(content), html_options)
73
+ content_tag("script".freeze, javascript_cdata_section(content), html_options)
74
74
  end
75
75
 
76
76
  def javascript_cdata_section(content) #:nodoc:
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  require 'active_support/core_ext/hash/keys'
4
2
  require 'active_support/core_ext/string/output_safety'
5
3
  require 'active_support/number_helper'
@@ -117,8 +115,8 @@ module ActionView
117
115
  # (defaults to current locale).
118
116
  # * <tt>:precision</tt> - Sets the precision of the number
119
117
  # (defaults to 3).
120
- # * <tt>:significant</tt> - If +true+, precision will be the #
121
- # of significant_digits. If +false+, the # of fractional
118
+ # * <tt>:significant</tt> - If +true+, precision will be the number
119
+ # of significant_digits. If +false+, the number of fractional
122
120
  # digits (defaults to +false+).
123
121
  # * <tt>:separator</tt> - Sets the separator between the
124
122
  # fractional and integer digits (defaults to ".").
@@ -141,7 +139,7 @@ module ActionView
141
139
  # number_to_percentage(302.24398923423, precision: 5) # => 302.24399%
142
140
  # number_to_percentage(1000, locale: :fr) # => 1 000,000%
143
141
  # number_to_percentage("98a") # => 98a%
144
- # number_to_percentage(100, format: "%n %") # => 100 %
142
+ # number_to_percentage(100, format: "%n %") # => 100.000 %
145
143
  #
146
144
  # number_to_percentage("98a", raise: true) # => InvalidNumberError
147
145
  def number_to_percentage(number, options = {})
@@ -192,8 +190,8 @@ module ActionView
192
190
  # (defaults to current locale).
193
191
  # * <tt>:precision</tt> - Sets the precision of the number
194
192
  # (defaults to 3).
195
- # * <tt>:significant</tt> - If +true+, precision will be the #
196
- # of significant_digits. If +false+, the # of fractional
193
+ # * <tt>:significant</tt> - If +true+, precision will be the number
194
+ # of significant_digits. If +false+, the number of fractional
197
195
  # digits (defaults to +false+).
198
196
  # * <tt>:separator</tt> - Sets the separator between the
199
197
  # fractional and integer digits (defaults to ".").
@@ -240,8 +238,8 @@ module ActionView
240
238
  # (defaults to current locale).
241
239
  # * <tt>:precision</tt> - Sets the precision of the number
242
240
  # (defaults to 3).
243
- # * <tt>:significant</tt> - If +true+, precision will be the #
244
- # of significant_digits. If +false+, the # of fractional
241
+ # * <tt>:significant</tt> - If +true+, precision will be the number
242
+ # of significant_digits. If +false+, the number of fractional
245
243
  # digits (defaults to +true+)
246
244
  # * <tt>:separator</tt> - Sets the separator between the
247
245
  # fractional and integer digits (defaults to ".").
@@ -280,7 +278,7 @@ module ActionView
280
278
  # See <tt>number_to_human_size</tt> if you want to print a file
281
279
  # size.
282
280
  #
283
- # You can also define you own unit-quantifier names if you want
281
+ # You can also define your own unit-quantifier names if you want
284
282
  # to use other decimal units (eg.: 1500 becomes "1.5
285
283
  # kilometers", 0.150 becomes "150 milliliters", etc). You may
286
284
  # define a wide range of unit quantifiers, even fractional ones
@@ -292,8 +290,8 @@ module ActionView
292
290
  # (defaults to current locale).
293
291
  # * <tt>:precision</tt> - Sets the precision of the number
294
292
  # (defaults to 3).
295
- # * <tt>:significant</tt> - If +true+, precision will be the #
296
- # of significant_digits. If +false+, the # of fractional
293
+ # * <tt>:significant</tt> - If +true+, precision will be the number
294
+ # of significant_digits. If +false+, the number of fractional
297
295
  # digits (defaults to +true+)
298
296
  # * <tt>:separator</tt> - Sets the separator between the
299
297
  # fractional and integer digits (defaults to ".").