actionview 7.1.1 → 7.2.3.1

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 (48) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +108 -311
  3. data/README.rdoc +1 -1
  4. data/app/assets/javascripts/rails-ujs.esm.js +0 -7
  5. data/lib/action_view/base.rb +25 -11
  6. data/lib/action_view/cache_expiry.rb +9 -3
  7. data/lib/action_view/dependency_tracker/{ripper_tracker.rb → ruby_tracker.rb} +4 -3
  8. data/lib/action_view/dependency_tracker.rb +1 -1
  9. data/lib/action_view/digestor.rb +6 -2
  10. data/lib/action_view/gem_version.rb +3 -3
  11. data/lib/action_view/helpers/asset_tag_helper.rb +26 -14
  12. data/lib/action_view/helpers/atom_feed_helper.rb +1 -1
  13. data/lib/action_view/helpers/cache_helper.rb +6 -6
  14. data/lib/action_view/helpers/capture_helper.rb +7 -1
  15. data/lib/action_view/helpers/csrf_helper.rb +1 -1
  16. data/lib/action_view/helpers/date_helper.rb +8 -1
  17. data/lib/action_view/helpers/form_helper.rb +230 -221
  18. data/lib/action_view/helpers/form_options_helper.rb +6 -3
  19. data/lib/action_view/helpers/form_tag_helper.rb +86 -53
  20. data/lib/action_view/helpers/number_helper.rb +35 -329
  21. data/lib/action_view/helpers/output_safety_helper.rb +5 -6
  22. data/lib/action_view/helpers/sanitize_helper.rb +25 -14
  23. data/lib/action_view/helpers/tag_helper.rb +213 -20
  24. data/lib/action_view/helpers/tags/collection_helpers.rb +2 -1
  25. data/lib/action_view/helpers/text_helper.rb +135 -72
  26. data/lib/action_view/helpers/url_helper.rb +8 -80
  27. data/lib/action_view/layouts.rb +10 -12
  28. data/lib/action_view/log_subscriber.rb +8 -4
  29. data/lib/action_view/railtie.rb +0 -1
  30. data/lib/action_view/render_parser/prism_render_parser.rb +127 -0
  31. data/lib/action_view/{ripper_ast_parser.rb → render_parser/ripper_render_parser.rb} +152 -9
  32. data/lib/action_view/render_parser.rb +21 -169
  33. data/lib/action_view/renderer/abstract_renderer.rb +1 -1
  34. data/lib/action_view/renderer/collection_renderer.rb +1 -1
  35. data/lib/action_view/renderer/partial_renderer.rb +2 -2
  36. data/lib/action_view/renderer/renderer.rb +32 -38
  37. data/lib/action_view/renderer/template_renderer.rb +3 -3
  38. data/lib/action_view/rendering.rb +4 -4
  39. data/lib/action_view/template/error.rb +11 -0
  40. data/lib/action_view/template/handlers/erb.rb +45 -37
  41. data/lib/action_view/template/renderable.rb +7 -1
  42. data/lib/action_view/template/resolver.rb +0 -2
  43. data/lib/action_view/template.rb +68 -19
  44. data/lib/action_view/test_case.rb +33 -34
  45. data/lib/action_view/unbound_template.rb +4 -4
  46. data/lib/action_view.rb +2 -1
  47. metadata +30 -19
  48. data/lib/assets/compiled/rails-ujs.js +0 -777
@@ -496,7 +496,8 @@ module ActionView
496
496
  # <option value="France">France</option>
497
497
  # </optgroup>
498
498
  #
499
- # Parameters:
499
+ # ==== Parameters
500
+ #
500
501
  # * +grouped_options+ - Accepts a nested array or hash of strings. The first value serves as the
501
502
  # <tt><optgroup></tt> label while the second value must be an array of options. The second value can be a
502
503
  # nested array of text-value pairs. See <tt>options_for_select</tt> for more info.
@@ -507,7 +508,8 @@ module ActionView
507
508
  # which will have the +selected+ attribute set. Note: It is possible for this value to match multiple options
508
509
  # as you might have the same option in multiple groups. Each will then get <tt>selected="selected"</tt>.
509
510
  #
510
- # Options:
511
+ # ==== Options
512
+ #
511
513
  # * <tt>:prompt</tt> - set to true or a prompt string. When the select element doesn't have a value yet, this
512
514
  # prepends an option with a generic prompt - "Please select" - or the given prompt string.
513
515
  # * <tt>:divider</tt> - the divider for the options groups.
@@ -599,7 +601,8 @@ module ActionView
599
601
 
600
602
  # Returns a string of option tags for the days of the week.
601
603
  #
602
- # Options:
604
+ # ====Options
605
+ #
603
606
  # * <tt>:index_as_value</tt> - Defaults to false, set to true to use the indexes from
604
607
  # <tt>I18n.translate("date.day_names")</tt> as the values. By default, Sunday is always 0.
605
608
  # * <tt>:day_format</tt> - The I18n key of the array to use for the weekday options.
@@ -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
@@ -522,25 +522,6 @@ module ActionView
522
522
  # submit_tag "Edit", class: "edit_button"
523
523
  # # => <input class="edit_button" data-disable-with="Edit" name="commit" type="submit" value="Edit" />
524
524
  #
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
525
  def submit_tag(value = "Save changes", options = {})
545
526
  options = options.deep_stringify_keys
546
527
  tag_options = { "type" => "submit", "name" => "commit", "value" => value }.update(options)
@@ -582,26 +563,6 @@ module ActionView
582
563
  # # <strong>Ask me!</strong>
583
564
  # # </button>
584
565
  #
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
566
  def button_tag(content_or_options = nil, options = nil, &block)
606
567
  if content_or_options.is_a? Hash
607
568
  options = content_or_options
@@ -675,11 +636,13 @@ module ActionView
675
636
  # <% end %>
676
637
  # # => <fieldset class="format"><p><input id="name" name="name" type="text" /></p></fieldset>
677
638
  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>")
639
+ content = []
640
+ content << content_tag("legend", legend) unless legend.blank?
641
+ content << capture(&block) if block_given?
642
+
643
+ content_tag(:fieldset, safe_join(content), options)
682
644
  end
645
+ alias_method :fieldset_tag, :field_set_tag
683
646
 
684
647
  # Creates a text field of type "color".
685
648
  #
@@ -762,14 +725,14 @@ module ActionView
762
725
  # date_field_tag 'name'
763
726
  # # => <input id="name" name="name" type="date" />
764
727
  #
765
- # date_field_tag 'date', '01/01/2014'
766
- # # => <input id="date" name="date" type="date" value="01/01/2014" />
728
+ # date_field_tag 'date', '2014-12-31'
729
+ # # => <input id="date" name="date" type="date" value="2014-12-31" />
767
730
  #
768
731
  # date_field_tag 'date', nil, class: 'special_input'
769
732
  # # => <input class="special_input" id="date" name="date" type="date" />
770
733
  #
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" />
734
+ # date_field_tag 'date', '2014-12-31', class: 'special_input', disabled: true
735
+ # # => <input disabled="disabled" class="special_input" id="date" name="date" type="date" value="2014-12-31" />
773
736
  def date_field_tag(name, value = nil, options = {})
774
737
  text_field_tag(name, value, options.merge(type: :date))
775
738
  end
@@ -784,6 +747,23 @@ module ActionView
784
747
  # * <tt>:max</tt> - The maximum acceptable value.
785
748
  # * <tt>:step</tt> - The acceptable value granularity.
786
749
  # * <tt>:include_seconds</tt> - Include seconds and ms in the output timestamp format (true by default).
750
+ #
751
+ # ==== Examples
752
+ #
753
+ # time_field_tag 'name'
754
+ # # => <input id="name" name="name" type="time" />
755
+ #
756
+ # time_field_tag 'time', '01:01'
757
+ # # => <input id="time" name="time" type="time" value="01:01" />
758
+ #
759
+ # time_field_tag 'time', nil, class: 'special_input'
760
+ # # => <input class="special_input" id="time" name="time" type="time" />
761
+ #
762
+ # time_field_tag 'time', '01:01', include_seconds: true
763
+ # # => <input id="time" name="time" type="time" value="01:01:00.000" />
764
+ #
765
+ # time_field_tag 'time', '01:01', min: '00:00', max: '23:59', step: 1
766
+ # # => <input id="time" max="23:59" min="00:00" name="time" step="1" type="time" value="01:01" />
787
767
  def time_field_tag(name, value = nil, options = {})
788
768
  text_field_tag(name, value, options.merge(type: :time))
789
769
  end
@@ -798,6 +778,20 @@ module ActionView
798
778
  # * <tt>:max</tt> - The maximum acceptable value.
799
779
  # * <tt>:step</tt> - The acceptable value granularity.
800
780
  # * <tt>:include_seconds</tt> - Include seconds in the output timestamp format (true by default).
781
+ #
782
+ # ==== Examples
783
+ #
784
+ # datetime_field_tag 'name'
785
+ # # => <input id="name" name="name" type="datetime-local" />
786
+ #
787
+ # datetime_field_tag 'datetime', '2014-01-01T01:01'
788
+ # # => <input id="datetime" name="datetime" type="datetime-local" value="2014-01-01T01:01" />
789
+ #
790
+ # datetime_field_tag 'datetime', nil, class: 'special_input'
791
+ # # => <input class="special_input" id="datetime" name="datetime" type="datetime-local" />
792
+ #
793
+ # datetime_field_tag 'datetime', '2014-01-01T01:01', class: 'special_input', disabled: true
794
+ # # => <input disabled="disabled" class="special_input" id="datetime" name="datetime" type="datetime-local" value="2014-01-01T01:01" />
801
795
  def datetime_field_tag(name, value = nil, options = {})
802
796
  text_field_tag(name, value, options.merge(type: "datetime-local"))
803
797
  end
@@ -813,6 +807,20 @@ module ActionView
813
807
  # * <tt>:min</tt> - The minimum acceptable value.
814
808
  # * <tt>:max</tt> - The maximum acceptable value.
815
809
  # * <tt>:step</tt> - The acceptable value granularity.
810
+ #
811
+ # ==== Examples
812
+ #
813
+ # month_field_tag 'name'
814
+ # # => <input id="name" name="name" type="month" />
815
+ #
816
+ # month_field_tag 'month', '2014-01'
817
+ # # => <input id="month" name="month" type="month" value="2014-01" />
818
+ #
819
+ # month_field_tag 'month', nil, class: 'special_input'
820
+ # # => <input class="special_input" id="month" name="month" type="month" />
821
+ #
822
+ # month_field_tag 'month', '2014-01', class: 'special_input', disabled: true
823
+ # # => <input disabled="disabled" class="special_input" id="month" name="month" type="month" value="2014-01" />
816
824
  def month_field_tag(name, value = nil, options = {})
817
825
  text_field_tag(name, value, options.merge(type: :month))
818
826
  end
@@ -826,6 +834,20 @@ module ActionView
826
834
  # * <tt>:min</tt> - The minimum acceptable value.
827
835
  # * <tt>:max</tt> - The maximum acceptable value.
828
836
  # * <tt>:step</tt> - The acceptable value granularity.
837
+ #
838
+ # ==== Examples
839
+ #
840
+ # week_field_tag 'name'
841
+ # # => <input id="name" name="name" type="week" />
842
+ #
843
+ # week_field_tag 'week', '2014-W01'
844
+ # # => <input id="week" name="week" type="week" value="2014-W01" />
845
+ #
846
+ # week_field_tag 'week', nil, class: 'special_input'
847
+ # # => <input class="special_input" id="week" name="week" type="week" />
848
+ #
849
+ # week_field_tag 'week', '2014-W01', class: 'special_input', disabled: true
850
+ # # => <input disabled="disabled" class="special_input" id="week" name="week" type="week" value="2014-W01" />
829
851
  def week_field_tag(name, value = nil, options = {})
830
852
  text_field_tag(name, value, options.merge(type: :week))
831
853
  end
@@ -934,6 +956,17 @@ module ActionView
934
956
  # ==== Options
935
957
  #
936
958
  # Supports the same options as #number_field_tag.
959
+ #
960
+ # ==== Examples
961
+ #
962
+ # range_field_tag 'quantity', '1'
963
+ # # => <input id="quantity" name="quantity" type="range" value="1" />
964
+ #
965
+ # range_field_tag 'quantity', in: 1...10
966
+ # # => <input id="quantity" name="quantity" min="1" max="9" type="range" />
967
+ #
968
+ # range_field_tag 'quantity', min: 1, max: 10, step: 2
969
+ # # => <input id="quantity" name="quantity" min="1" max="10" step="2" type="range"
937
970
  def range_field_tag(name, value = nil, options = {})
938
971
  number_field_tag(name, value, options.merge(type: :range))
939
972
  end