actionview 7.1.2 → 8.0.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.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +51 -382
  3. data/lib/action_view/base.rb +25 -11
  4. data/lib/action_view/cache_expiry.rb +9 -3
  5. data/lib/action_view/dependency_tracker/erb_tracker.rb +36 -27
  6. data/lib/action_view/dependency_tracker/ruby_tracker.rb +43 -0
  7. data/lib/action_view/dependency_tracker/wildcard_resolver.rb +32 -0
  8. data/lib/action_view/dependency_tracker.rb +2 -1
  9. data/lib/action_view/digestor.rb +6 -2
  10. data/lib/action_view/gem_version.rb +2 -2
  11. data/lib/action_view/helpers/asset_tag_helper.rb +18 -6
  12. data/lib/action_view/helpers/atom_feed_helper.rb +0 -2
  13. data/lib/action_view/helpers/cache_helper.rb +14 -6
  14. data/lib/action_view/helpers/csrf_helper.rb +1 -1
  15. data/lib/action_view/helpers/date_helper.rb +3 -3
  16. data/lib/action_view/helpers/form_helper.rb +282 -273
  17. data/lib/action_view/helpers/form_options_helper.rb +23 -21
  18. data/lib/action_view/helpers/form_tag_helper.rb +104 -69
  19. data/lib/action_view/helpers/number_helper.rb +35 -329
  20. data/lib/action_view/helpers/output_safety_helper.rb +5 -6
  21. data/lib/action_view/helpers/rendering_helper.rb +160 -50
  22. data/lib/action_view/helpers/sanitize_helper.rb +31 -14
  23. data/lib/action_view/helpers/tag_helper.rb +196 -19
  24. data/lib/action_view/helpers/tags/collection_check_boxes.rb +4 -3
  25. data/lib/action_view/helpers/tags/collection_helpers.rb +2 -1
  26. data/lib/action_view/helpers/text_helper.rb +125 -69
  27. data/lib/action_view/helpers/url_helper.rb +6 -80
  28. data/lib/action_view/layouts.rb +11 -13
  29. data/lib/action_view/log_subscriber.rb +8 -4
  30. data/lib/action_view/railtie.rb +0 -1
  31. data/lib/action_view/record_identifier.rb +1 -1
  32. data/lib/action_view/render_parser/prism_render_parser.rb +139 -0
  33. data/lib/action_view/{ripper_ast_parser.rb → render_parser/ripper_render_parser.rb} +162 -10
  34. data/lib/action_view/render_parser.rb +21 -169
  35. data/lib/action_view/renderer/abstract_renderer.rb +1 -1
  36. data/lib/action_view/renderer/partial_renderer.rb +2 -2
  37. data/lib/action_view/renderer/renderer.rb +32 -38
  38. data/lib/action_view/renderer/streaming_template_renderer.rb +0 -1
  39. data/lib/action_view/renderer/template_renderer.rb +3 -3
  40. data/lib/action_view/rendering.rb +6 -7
  41. data/lib/action_view/template/error.rb +11 -0
  42. data/lib/action_view/template/handlers/erb.rb +45 -37
  43. data/lib/action_view/template/renderable.rb +7 -1
  44. data/lib/action_view/template/resolver.rb +0 -3
  45. data/lib/action_view/template.rb +46 -12
  46. data/lib/action_view/test_case.rb +14 -16
  47. data/lib/action_view/unbound_template.rb +4 -4
  48. data/lib/action_view.rb +1 -1
  49. metadata +17 -19
  50. data/lib/action_view/dependency_tracker/ripper_tracker.rb +0 -59
  51. data/lib/assets/compiled/rails-ujs.js +0 -777
@@ -686,7 +686,7 @@ module ActionView
686
686
  # if a +User+ model has a +category_id+ field and in the form no category is selected, no +category_id+ parameter is sent. So,
687
687
  # any strong parameters idiom like:
688
688
  #
689
- # params.require(:user).permit(...)
689
+ # params.expect(user: [...])
690
690
  #
691
691
  # will raise an error since no <tt>{user: ...}</tt> will be present.
692
692
  #
@@ -723,7 +723,7 @@ module ActionView
723
723
  # end
724
724
  #
725
725
  # Sample usage (selecting the associated Author for an instance of Post, <tt>@post</tt>):
726
- # collection_check_boxes(:post, :author_ids, Author.all, :id, :name_with_initial)
726
+ # collection_checkboxes(:post, :author_ids, Author.all, :id, :name_with_initial)
727
727
  #
728
728
  # If <tt>@post.author_ids</tt> is already <tt>[1]</tt>, this would return:
729
729
  # <input id="post_author_ids_1" name="post[author_ids][]" type="checkbox" value="1" checked="checked" />
@@ -736,8 +736,8 @@ module ActionView
736
736
  #
737
737
  # It is also possible to customize the way the elements will be shown by
738
738
  # giving a block to the method:
739
- # collection_check_boxes(:post, :author_ids, Author.all, :id, :name_with_initial) do |b|
740
- # b.label { b.check_box }
739
+ # collection_checkboxes(:post, :author_ids, Author.all, :id, :name_with_initial) do |b|
740
+ # b.label { b.checkbox }
741
741
  # end
742
742
  #
743
743
  # The argument passed to the block is a special kind of builder for this
@@ -746,17 +746,17 @@ module ActionView
746
746
  # Using it, you can change the label and check box display order or even
747
747
  # use the label as wrapper, as in the example above.
748
748
  #
749
- # The builder methods <tt>label</tt> and <tt>check_box</tt> also accept
749
+ # The builder methods <tt>label</tt> and <tt>checkbox</tt> also accept
750
750
  # extra HTML options:
751
- # collection_check_boxes(:post, :author_ids, Author.all, :id, :name_with_initial) do |b|
752
- # b.label(class: "check_box") { b.check_box(class: "check_box") }
751
+ # collection_checkboxes(:post, :author_ids, Author.all, :id, :name_with_initial) do |b|
752
+ # b.label(class: "checkbox") { b.checkbox(class: "checkbox") }
753
753
  # end
754
754
  #
755
755
  # There are also three special methods available: <tt>object</tt>, <tt>text</tt> and
756
756
  # <tt>value</tt>, which are the current item being rendered, its text and value methods,
757
757
  # respectively. You can use them like this:
758
- # collection_check_boxes(:post, :author_ids, Author.all, :id, :name_with_initial) do |b|
759
- # b.label(:"data-value" => b.value) { b.check_box + b.text }
758
+ # collection_checkboxes(:post, :author_ids, Author.all, :id, :name_with_initial) do |b|
759
+ # b.label(:"data-value" => b.value) { b.checkbox + b.text }
760
760
  # end
761
761
  #
762
762
  # ==== Gotcha
@@ -779,9 +779,10 @@ module ActionView
779
779
  #
780
780
  # In the rare case you don't want this hidden field, you can pass the
781
781
  # <tt>include_hidden: false</tt> option to the helper method.
782
- def collection_check_boxes(object, method, collection, value_method, text_method, options = {}, html_options = {}, &block)
782
+ def collection_checkboxes(object, method, collection, value_method, text_method, options = {}, html_options = {}, &block)
783
783
  Tags::CollectionCheckBoxes.new(object, method, self, collection, value_method, text_method, options, html_options).render(&block)
784
784
  end
785
+ alias_method :collection_check_boxes, :collection_checkboxes
785
786
 
786
787
  private
787
788
  def option_html_attributes(element)
@@ -839,7 +840,7 @@ module ActionView
839
840
  class FormBuilder
840
841
  # Wraps ActionView::Helpers::FormOptionsHelper#select for form builders:
841
842
  #
842
- # <%= form_for @post do |f| %>
843
+ # <%= form_with model: @post do |f| %>
843
844
  # <%= f.select :person_id, Person.all.collect { |p| [ p.name, p.id ] }, include_blank: true %>
844
845
  # <%= f.submit %>
845
846
  # <% end %>
@@ -851,7 +852,7 @@ module ActionView
851
852
 
852
853
  # Wraps ActionView::Helpers::FormOptionsHelper#collection_select for form builders:
853
854
  #
854
- # <%= form_for @post do |f| %>
855
+ # <%= form_with model: @post do |f| %>
855
856
  # <%= f.collection_select :person_id, Author.all, :id, :name_with_initial, prompt: true %>
856
857
  # <%= f.submit %>
857
858
  # <% end %>
@@ -863,7 +864,7 @@ module ActionView
863
864
 
864
865
  # Wraps ActionView::Helpers::FormOptionsHelper#grouped_collection_select for form builders:
865
866
  #
866
- # <%= form_for @city do |f| %>
867
+ # <%= form_with model: @city do |f| %>
867
868
  # <%= f.grouped_collection_select :country_id, @continents, :countries, :name, :id, :name %>
868
869
  # <%= f.submit %>
869
870
  # <% end %>
@@ -875,7 +876,7 @@ module ActionView
875
876
 
876
877
  # Wraps ActionView::Helpers::FormOptionsHelper#time_zone_select for form builders:
877
878
  #
878
- # <%= form_for @user do |f| %>
879
+ # <%= form_with model: @user do |f| %>
879
880
  # <%= f.time_zone_select :time_zone, nil, include_blank: true %>
880
881
  # <%= f.submit %>
881
882
  # <% end %>
@@ -887,7 +888,7 @@ module ActionView
887
888
 
888
889
  # Wraps ActionView::Helpers::FormOptionsHelper#weekday_select for form builders:
889
890
  #
890
- # <%= form_for @user do |f| %>
891
+ # <%= form_with model: @user do |f| %>
891
892
  # <%= f.weekday_select :weekday, include_blank: true %>
892
893
  # <%= f.submit %>
893
894
  # <% end %>
@@ -897,21 +898,22 @@ module ActionView
897
898
  @template.weekday_select(@object_name, method, objectify_options(options), @default_html_options.merge(html_options))
898
899
  end
899
900
 
900
- # Wraps ActionView::Helpers::FormOptionsHelper#collection_check_boxes for form builders:
901
+ # Wraps ActionView::Helpers::FormOptionsHelper#collection_checkboxes for form builders:
901
902
  #
902
- # <%= form_for @post do |f| %>
903
- # <%= f.collection_check_boxes :author_ids, Author.all, :id, :name_with_initial %>
903
+ # <%= form_with model: @post do |f| %>
904
+ # <%= f.collection_checkboxes :author_ids, Author.all, :id, :name_with_initial %>
904
905
  # <%= f.submit %>
905
906
  # <% end %>
906
907
  #
907
908
  # Please refer to the documentation of the base helper for details.
908
- def collection_check_boxes(method, collection, value_method, text_method, options = {}, html_options = {}, &block)
909
- @template.collection_check_boxes(@object_name, method, collection, value_method, text_method, objectify_options(options), @default_html_options.merge(html_options), &block)
909
+ def collection_checkboxes(method, collection, value_method, text_method, options = {}, html_options = {}, &block)
910
+ @template.collection_checkboxes(@object_name, method, collection, value_method, text_method, objectify_options(options), @default_html_options.merge(html_options), &block)
910
911
  end
912
+ alias_method :collection_check_boxes, :collection_checkboxes
911
913
 
912
914
  # Wraps ActionView::Helpers::FormOptionsHelper#collection_radio_buttons for form builders:
913
915
  #
914
- # <%= form_for @post do |f| %>
916
+ # <%= form_with model: @post do |f| %>
915
917
  # <%= f.collection_radio_buttons :author_id, Author.all, :id, :name_with_initial %>
916
918
  # <%= f.submit %>
917
919
  # <% end %>
@@ -91,11 +91,11 @@ module ActionView
91
91
  # attribute name.
92
92
  #
93
93
  # <%= label_tag :post, :title %>
94
- # <%= text_field_tag :post, :title, aria: { describedby: field_id(:post, :title, :error) } %>
94
+ # <%= text_field :post, :title, aria: { describedby: field_id(:post, :title, :error) } %>
95
95
  # <%= tag.span("is blank", id: field_id(:post, :title, :error) %>
96
96
  #
97
97
  # In the example above, the <tt><input type="text"></tt> element built by
98
- # the call to <tt>text_field_tag</tt> declares an
98
+ # the call to <tt>text_field</tt> declares an
99
99
  # <tt>aria-describedby</tt> attribute referencing the <tt><span></tt>
100
100
  # element, sharing a common <tt>id</tt> root (<tt>post_title</tt>, in this
101
101
  # case).
@@ -123,11 +123,11 @@ module ActionView
123
123
  # Return the value generated by the <tt>FormBuilder</tt> for the given
124
124
  # attribute name.
125
125
  #
126
- # <%= text_field_tag :post, :title, name: field_name(:post, :title, :subtitle) %>
127
- # <%# => <input type="text" name="post[title][subtitle]">
126
+ # <%= text_field :post, :title, name: field_name(:post, :title, :subtitle) %>
127
+ # <%# => <input type="text" name="post[title][subtitle]"> %>
128
128
  #
129
- # <%= text_field_tag :post, :tag, name: field_name(:post, :tag, multiple: true) %>
130
- # <%# => <input type="text" name="post[tag][]">
129
+ # <%= text_field :post, :tag, name: field_name(:post, :tag, multiple: true) %>
130
+ # <%# => <input type="text" name="post[tag][]"> %>
131
131
  #
132
132
  def field_name(object_name, method_name, *method_names, multiple: false, index: nil)
133
133
  names = method_names.map! { |name| "[#{name}]" }.join
@@ -393,24 +393,24 @@ module ActionView
393
393
  # * Any other key creates standard HTML attributes for the tag.
394
394
  #
395
395
  # ==== Examples
396
- # text_area_tag 'post'
396
+ # textarea_tag 'post'
397
397
  # # => <textarea id="post" name="post"></textarea>
398
398
  #
399
- # text_area_tag 'bio', @user.bio
399
+ # textarea_tag 'bio', @user.bio
400
400
  # # => <textarea id="bio" name="bio">This is my biography.</textarea>
401
401
  #
402
- # text_area_tag 'body', nil, rows: 10, cols: 25
402
+ # textarea_tag 'body', nil, rows: 10, cols: 25
403
403
  # # => <textarea cols="25" id="body" name="body" rows="10"></textarea>
404
404
  #
405
- # text_area_tag 'body', nil, size: "25x10"
405
+ # textarea_tag 'body', nil, size: "25x10"
406
406
  # # => <textarea name="body" id="body" cols="25" rows="10"></textarea>
407
407
  #
408
- # text_area_tag 'description', "Description goes here.", disabled: true
408
+ # textarea_tag 'description', "Description goes here.", disabled: true
409
409
  # # => <textarea disabled="disabled" id="description" name="description">Description goes here.</textarea>
410
410
  #
411
- # text_area_tag 'comment', nil, class: 'comment_input'
411
+ # textarea_tag 'comment', nil, class: 'comment_input'
412
412
  # # => <textarea class="comment_input" id="comment" name="comment"></textarea>
413
- def text_area_tag(name, content = nil, options = {})
413
+ def textarea_tag(name, content = nil, options = {})
414
414
  options = options.stringify_keys
415
415
 
416
416
  if size = options.delete("size")
@@ -422,12 +422,13 @@ module ActionView
422
422
 
423
423
  content_tag :textarea, content.to_s.html_safe, { "name" => name, "id" => sanitize_to_id(name) }.update(options)
424
424
  end
425
+ alias_method :text_area_tag, :textarea_tag
425
426
 
426
427
  ##
427
428
  # :call-seq:
428
- # check_box_tag(name, options = {})
429
- # check_box_tag(name, value, options = {})
430
- # check_box_tag(name, value, checked, options = {})
429
+ # checkbox_tag(name, options = {})
430
+ # checkbox_tag(name, value, options = {})
431
+ # checkbox_tag(name, value, checked, options = {})
431
432
  #
432
433
  # Creates a check box form input tag.
433
434
  #
@@ -438,21 +439,21 @@ module ActionView
438
439
  # * Any other key creates standard HTML options for the tag.
439
440
  #
440
441
  # ==== Examples
441
- # check_box_tag 'accept'
442
+ # checkbox_tag 'accept'
442
443
  # # => <input id="accept" name="accept" type="checkbox" value="1" />
443
444
  #
444
- # check_box_tag 'rock', 'rock music'
445
+ # checkbox_tag 'rock', 'rock music'
445
446
  # # => <input id="rock" name="rock" type="checkbox" value="rock music" />
446
447
  #
447
- # check_box_tag 'receive_email', 'yes', true
448
+ # checkbox_tag 'receive_email', 'yes', true
448
449
  # # => <input checked="checked" id="receive_email" name="receive_email" type="checkbox" value="yes" />
449
450
  #
450
- # check_box_tag 'tos', 'yes', false, class: 'accept_tos'
451
+ # checkbox_tag 'tos', 'yes', false, class: 'accept_tos'
451
452
  # # => <input class="accept_tos" id="tos" name="tos" type="checkbox" value="yes" />
452
453
  #
453
- # check_box_tag 'eula', 'accepted', false, disabled: true
454
+ # checkbox_tag 'eula', 'accepted', false, disabled: true
454
455
  # # => <input disabled="disabled" id="eula" name="eula" type="checkbox" value="accepted" />
455
- def check_box_tag(name, *args)
456
+ def checkbox_tag(name, *args)
456
457
  if args.length >= 4
457
458
  raise ArgumentError, "wrong number of arguments (given #{args.length + 1}, expected 1..4)"
458
459
  end
@@ -462,6 +463,7 @@ module ActionView
462
463
  html_options["checked"] = "checked" if checked
463
464
  tag :input, html_options
464
465
  end
466
+ alias_method :check_box_tag, :checkbox_tag
465
467
 
466
468
  ##
467
469
  # :call-seq:
@@ -522,25 +524,6 @@ module ActionView
522
524
  # submit_tag "Edit", class: "edit_button"
523
525
  # # => <input class="edit_button" data-disable-with="Edit" name="commit" type="submit" value="Edit" />
524
526
  #
525
- # ==== Deprecated: \Rails UJS attributes
526
- #
527
- # Prior to \Rails 7, \Rails shipped with the JavaScript library called @rails/ujs on by default. Following \Rails 7,
528
- # this library is no longer on by default. This library integrated with the following options:
529
- #
530
- # * <tt>confirm: 'question?'</tt> - If present the unobtrusive JavaScript
531
- # drivers will provide a prompt with the question specified. If the user accepts,
532
- # the form is processed normally, otherwise no action is taken.
533
- # * <tt>:disable_with</tt> - Value of this parameter will be used as the value for a
534
- # disabled version of the submit button when the form is submitted. This feature is
535
- # provided by the unobtrusive JavaScript driver. To disable this feature for a single submit tag
536
- # pass <tt>:data => { disable_with: false }</tt> Defaults to value attribute.
537
- #
538
- # submit_tag "Complete sale", data: { disable_with: "Submitting..." }
539
- # # => <input name="commit" data-disable-with="Submitting..." type="submit" value="Complete sale" />
540
- #
541
- # submit_tag "Save", data: { confirm: "Are you sure?" }
542
- # # => <input name='commit' type='submit' value='Save' data-disable-with="Save" data-confirm="Are you sure?" />
543
- #
544
527
  def submit_tag(value = "Save changes", options = {})
545
528
  options = options.deep_stringify_keys
546
529
  tag_options = { "type" => "submit", "name" => "commit", "value" => value }.update(options)
@@ -582,26 +565,6 @@ module ActionView
582
565
  # # <strong>Ask me!</strong>
583
566
  # # </button>
584
567
  #
585
- # ==== Deprecated: \Rails UJS attributes
586
- #
587
- # Prior to \Rails 7, \Rails shipped with a JavaScript library called @rails/ujs on by default. Following \Rails 7,
588
- # this library is no longer on by default. This library integrated with the following options:
589
- #
590
- # * <tt>confirm: 'question?'</tt> - If present, the
591
- # unobtrusive JavaScript drivers will provide a prompt with
592
- # the question specified. If the user accepts, the form is
593
- # processed normally, otherwise no action is taken.
594
- # * <tt>:disable_with</tt> - Value of this parameter will be
595
- # used as the value for a disabled version of the submit
596
- # button when the form is submitted. This feature is provided
597
- # by the unobtrusive JavaScript driver.
598
- #
599
- # button_tag "Save", data: { confirm: "Are you sure?" }
600
- # # => <button name="button" type="submit" data-confirm="Are you sure?">Save</button>
601
- #
602
- # button_tag "Checkout", data: { disable_with: "Please wait..." }
603
- # # => <button data-disable-with="Please wait..." name="button" type="submit">Checkout</button>
604
- #
605
568
  def button_tag(content_or_options = nil, options = nil, &block)
606
569
  if content_or_options.is_a? Hash
607
570
  options = content_or_options
@@ -675,11 +638,13 @@ module ActionView
675
638
  # <% end %>
676
639
  # # => <fieldset class="format"><p><input id="name" name="name" type="text" /></p></fieldset>
677
640
  def field_set_tag(legend = nil, options = nil, &block)
678
- output = tag(:fieldset, options, true)
679
- output.safe_concat(content_tag("legend", legend)) unless legend.blank?
680
- output.concat(capture(&block)) if block_given?
681
- output.safe_concat("</fieldset>")
641
+ content = []
642
+ content << content_tag("legend", legend) unless legend.blank?
643
+ content << capture(&block) if block_given?
644
+
645
+ content_tag(:fieldset, safe_join(content), options)
682
646
  end
647
+ alias_method :fieldset_tag, :field_set_tag
683
648
 
684
649
  # Creates a text field of type "color".
685
650
  #
@@ -762,14 +727,14 @@ module ActionView
762
727
  # date_field_tag 'name'
763
728
  # # => <input id="name" name="name" type="date" />
764
729
  #
765
- # date_field_tag 'date', '01/01/2014'
766
- # # => <input id="date" name="date" type="date" value="01/01/2014" />
730
+ # date_field_tag 'date', '2014-12-31'
731
+ # # => <input id="date" name="date" type="date" value="2014-12-31" />
767
732
  #
768
733
  # date_field_tag 'date', nil, class: 'special_input'
769
734
  # # => <input class="special_input" id="date" name="date" type="date" />
770
735
  #
771
- # date_field_tag 'date', '01/01/2014', class: 'special_input', disabled: true
772
- # # => <input disabled="disabled" class="special_input" id="date" name="date" type="date" value="01/01/2014" />
736
+ # date_field_tag 'date', '2014-12-31', class: 'special_input', disabled: true
737
+ # # => <input disabled="disabled" class="special_input" id="date" name="date" type="date" value="2014-12-31" />
773
738
  def date_field_tag(name, value = nil, options = {})
774
739
  text_field_tag(name, value, options.merge(type: :date))
775
740
  end
@@ -784,6 +749,23 @@ module ActionView
784
749
  # * <tt>:max</tt> - The maximum acceptable value.
785
750
  # * <tt>:step</tt> - The acceptable value granularity.
786
751
  # * <tt>:include_seconds</tt> - Include seconds and ms in the output timestamp format (true by default).
752
+ #
753
+ # ==== Examples
754
+ #
755
+ # time_field_tag 'name'
756
+ # # => <input id="name" name="name" type="time" />
757
+ #
758
+ # time_field_tag 'time', '01:01'
759
+ # # => <input id="time" name="time" type="time" value="01:01" />
760
+ #
761
+ # time_field_tag 'time', nil, class: 'special_input'
762
+ # # => <input class="special_input" id="time" name="time" type="time" />
763
+ #
764
+ # time_field_tag 'time', '01:01', include_seconds: true
765
+ # # => <input id="time" name="time" type="time" value="01:01:00.000" />
766
+ #
767
+ # time_field_tag 'time', '01:01', min: '00:00', max: '23:59', step: 1
768
+ # # => <input id="time" max="23:59" min="00:00" name="time" step="1" type="time" value="01:01" />
787
769
  def time_field_tag(name, value = nil, options = {})
788
770
  text_field_tag(name, value, options.merge(type: :time))
789
771
  end
@@ -798,6 +780,20 @@ module ActionView
798
780
  # * <tt>:max</tt> - The maximum acceptable value.
799
781
  # * <tt>:step</tt> - The acceptable value granularity.
800
782
  # * <tt>:include_seconds</tt> - Include seconds in the output timestamp format (true by default).
783
+ #
784
+ # ==== Examples
785
+ #
786
+ # datetime_field_tag 'name'
787
+ # # => <input id="name" name="name" type="datetime-local" />
788
+ #
789
+ # datetime_field_tag 'datetime', '2014-01-01T01:01'
790
+ # # => <input id="datetime" name="datetime" type="datetime-local" value="2014-01-01T01:01" />
791
+ #
792
+ # datetime_field_tag 'datetime', nil, class: 'special_input'
793
+ # # => <input class="special_input" id="datetime" name="datetime" type="datetime-local" />
794
+ #
795
+ # datetime_field_tag 'datetime', '2014-01-01T01:01', class: 'special_input', disabled: true
796
+ # # => <input disabled="disabled" class="special_input" id="datetime" name="datetime" type="datetime-local" value="2014-01-01T01:01" />
801
797
  def datetime_field_tag(name, value = nil, options = {})
802
798
  text_field_tag(name, value, options.merge(type: "datetime-local"))
803
799
  end
@@ -813,6 +809,20 @@ module ActionView
813
809
  # * <tt>:min</tt> - The minimum acceptable value.
814
810
  # * <tt>:max</tt> - The maximum acceptable value.
815
811
  # * <tt>:step</tt> - The acceptable value granularity.
812
+ #
813
+ # ==== Examples
814
+ #
815
+ # month_field_tag 'name'
816
+ # # => <input id="name" name="name" type="month" />
817
+ #
818
+ # month_field_tag 'month', '2014-01'
819
+ # # => <input id="month" name="month" type="month" value="2014-01" />
820
+ #
821
+ # month_field_tag 'month', nil, class: 'special_input'
822
+ # # => <input class="special_input" id="month" name="month" type="month" />
823
+ #
824
+ # month_field_tag 'month', '2014-01', class: 'special_input', disabled: true
825
+ # # => <input disabled="disabled" class="special_input" id="month" name="month" type="month" value="2014-01" />
816
826
  def month_field_tag(name, value = nil, options = {})
817
827
  text_field_tag(name, value, options.merge(type: :month))
818
828
  end
@@ -826,6 +836,20 @@ module ActionView
826
836
  # * <tt>:min</tt> - The minimum acceptable value.
827
837
  # * <tt>:max</tt> - The maximum acceptable value.
828
838
  # * <tt>:step</tt> - The acceptable value granularity.
839
+ #
840
+ # ==== Examples
841
+ #
842
+ # week_field_tag 'name'
843
+ # # => <input id="name" name="name" type="week" />
844
+ #
845
+ # week_field_tag 'week', '2014-W01'
846
+ # # => <input id="week" name="week" type="week" value="2014-W01" />
847
+ #
848
+ # week_field_tag 'week', nil, class: 'special_input'
849
+ # # => <input class="special_input" id="week" name="week" type="week" />
850
+ #
851
+ # week_field_tag 'week', '2014-W01', class: 'special_input', disabled: true
852
+ # # => <input disabled="disabled" class="special_input" id="week" name="week" type="week" value="2014-W01" />
829
853
  def week_field_tag(name, value = nil, options = {})
830
854
  text_field_tag(name, value, options.merge(type: :week))
831
855
  end
@@ -934,6 +958,17 @@ module ActionView
934
958
  # ==== Options
935
959
  #
936
960
  # Supports the same options as #number_field_tag.
961
+ #
962
+ # ==== Examples
963
+ #
964
+ # range_field_tag 'quantity', '1'
965
+ # # => <input id="quantity" name="quantity" type="range" value="1" />
966
+ #
967
+ # range_field_tag 'quantity', in: 1...10
968
+ # # => <input id="quantity" name="quantity" min="1" max="9" type="range" />
969
+ #
970
+ # range_field_tag 'quantity', min: 1, max: 10, step: 2
971
+ # # => <input id="quantity" name="quantity" min="1" max="10" step="2" type="range"
937
972
  def range_field_tag(name, value = nil, options = {})
938
973
  number_field_tag(name, value, options.merge(type: :range))
939
974
  end