actionview 6.1.7.2 → 7.1.3
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +299 -277
- data/MIT-LICENSE +2 -1
- data/README.rdoc +3 -3
- data/app/assets/javascripts/rails-ujs.esm.js +686 -0
- data/app/assets/javascripts/rails-ujs.js +630 -0
- data/lib/action_view/base.rb +37 -19
- data/lib/action_view/buffers.rb +107 -9
- data/lib/action_view/cache_expiry.rb +48 -37
- data/lib/action_view/context.rb +1 -1
- data/lib/action_view/dependency_tracker/erb_tracker.rb +154 -0
- data/lib/action_view/dependency_tracker/ripper_tracker.rb +59 -0
- data/lib/action_view/dependency_tracker.rb +6 -147
- data/lib/action_view/deprecator.rb +7 -0
- data/lib/action_view/digestor.rb +8 -5
- data/lib/action_view/flows.rb +4 -4
- data/lib/action_view/gem_version.rb +4 -4
- data/lib/action_view/helpers/active_model_helper.rb +3 -3
- data/lib/action_view/helpers/asset_tag_helper.rb +200 -60
- data/lib/action_view/helpers/asset_url_helper.rb +22 -21
- data/lib/action_view/helpers/atom_feed_helper.rb +8 -9
- data/lib/action_view/helpers/cache_helper.rb +55 -12
- data/lib/action_view/helpers/capture_helper.rb +34 -14
- data/lib/action_view/helpers/content_exfiltration_prevention_helper.rb +70 -0
- data/lib/action_view/helpers/controller_helper.rb +8 -2
- data/lib/action_view/helpers/csp_helper.rb +3 -3
- data/lib/action_view/helpers/csrf_helper.rb +4 -4
- data/lib/action_view/helpers/date_helper.rb +123 -57
- data/lib/action_view/helpers/debug_helper.rb +6 -4
- data/lib/action_view/helpers/form_helper.rb +253 -97
- data/lib/action_view/helpers/form_options_helper.rb +72 -34
- data/lib/action_view/helpers/form_tag_helper.rb +189 -58
- data/lib/action_view/helpers/javascript_helper.rb +4 -5
- data/lib/action_view/helpers/number_helper.rb +43 -335
- data/lib/action_view/helpers/output_safety_helper.rb +6 -6
- data/lib/action_view/helpers/rendering_helper.rb +6 -7
- data/lib/action_view/helpers/sanitize_helper.rb +54 -24
- data/lib/action_view/helpers/tag_helper.rb +42 -35
- data/lib/action_view/helpers/tags/base.rb +16 -77
- data/lib/action_view/helpers/tags/check_box.rb +1 -1
- data/lib/action_view/helpers/tags/collection_check_boxes.rb +1 -0
- data/lib/action_view/helpers/tags/collection_radio_buttons.rb +1 -0
- data/lib/action_view/helpers/tags/collection_select.rb +4 -1
- data/lib/action_view/helpers/tags/date_field.rb +1 -1
- data/lib/action_view/helpers/tags/date_select.rb +2 -0
- data/lib/action_view/helpers/tags/datetime_field.rb +14 -6
- data/lib/action_view/helpers/tags/datetime_local_field.rb +11 -2
- data/lib/action_view/helpers/tags/file_field.rb +16 -0
- data/lib/action_view/helpers/tags/grouped_collection_select.rb +3 -0
- data/lib/action_view/helpers/tags/month_field.rb +1 -1
- data/lib/action_view/helpers/tags/select.rb +4 -1
- data/lib/action_view/helpers/tags/select_renderer.rb +56 -0
- data/lib/action_view/helpers/tags/time_field.rb +11 -2
- data/lib/action_view/helpers/tags/time_zone_select.rb +3 -0
- data/lib/action_view/helpers/tags/week_field.rb +1 -1
- data/lib/action_view/helpers/tags/weekday_select.rb +31 -0
- data/lib/action_view/helpers/tags.rb +5 -2
- data/lib/action_view/helpers/text_helper.rb +180 -97
- data/lib/action_view/helpers/translation_helper.rb +14 -45
- data/lib/action_view/helpers/url_helper.rb +230 -132
- data/lib/action_view/helpers.rb +27 -25
- data/lib/action_view/layouts.rb +15 -10
- data/lib/action_view/log_subscriber.rb +49 -32
- data/lib/action_view/lookup_context.rb +58 -61
- data/lib/action_view/model_naming.rb +2 -2
- data/lib/action_view/path_registry.rb +57 -0
- data/lib/action_view/path_set.rb +28 -35
- data/lib/action_view/railtie.rb +44 -9
- data/lib/action_view/record_identifier.rb +16 -9
- data/lib/action_view/render_parser.rb +188 -0
- data/lib/action_view/renderer/abstract_renderer.rb +3 -3
- data/lib/action_view/renderer/collection_renderer.rb +10 -2
- data/lib/action_view/renderer/partial_renderer/collection_caching.rb +21 -3
- data/lib/action_view/renderer/partial_renderer.rb +3 -36
- data/lib/action_view/renderer/renderer.rb +6 -4
- data/lib/action_view/renderer/streaming_template_renderer.rb +6 -5
- data/lib/action_view/renderer/template_renderer.rb +9 -4
- data/lib/action_view/rendering.rb +25 -7
- data/lib/action_view/ripper_ast_parser.rb +198 -0
- data/lib/action_view/routing_url_for.rb +8 -5
- data/lib/action_view/template/error.rb +122 -14
- data/lib/action_view/template/handlers/builder.rb +4 -4
- data/lib/action_view/template/handlers/erb/erubi.rb +23 -27
- data/lib/action_view/template/handlers/erb.rb +79 -1
- data/lib/action_view/template/handlers.rb +4 -4
- data/lib/action_view/template/html.rb +4 -4
- data/lib/action_view/template/inline.rb +3 -3
- data/lib/action_view/template/raw_file.rb +4 -4
- data/lib/action_view/template/renderable.rb +1 -1
- data/lib/action_view/template/resolver.rb +96 -313
- data/lib/action_view/template/text.rb +4 -4
- data/lib/action_view/template/types.rb +25 -32
- data/lib/action_view/template.rb +245 -41
- data/lib/action_view/template_details.rb +66 -0
- data/lib/action_view/template_path.rb +66 -0
- data/lib/action_view/test_case.rb +182 -23
- data/lib/action_view/testing/resolvers.rb +11 -12
- data/lib/action_view/unbound_template.rb +43 -7
- data/lib/action_view/version.rb +1 -1
- data/lib/action_view/view_paths.rb +19 -28
- data/lib/action_view.rb +6 -4
- data/lib/assets/compiled/rails-ujs.js +36 -5
- metadata +32 -25
|
@@ -9,8 +9,8 @@ require "active_support/core_ext/object/acts_like"
|
|
|
9
9
|
require "active_support/core_ext/object/with_options"
|
|
10
10
|
|
|
11
11
|
module ActionView
|
|
12
|
-
module Helpers
|
|
13
|
-
# = Action View Date Helpers
|
|
12
|
+
module Helpers # :nodoc:
|
|
13
|
+
# = Action View \Date \Helpers
|
|
14
14
|
#
|
|
15
15
|
# The Date Helper primarily creates select/option tags for different kinds of dates and times or date and time
|
|
16
16
|
# elements. All of the select-type methods share a number of common options that are as follows:
|
|
@@ -26,7 +26,7 @@ module ActionView
|
|
|
26
26
|
MINUTES_IN_QUARTER_YEAR = 131400
|
|
27
27
|
MINUTES_IN_THREE_QUARTERS_YEAR = 394200
|
|
28
28
|
|
|
29
|
-
# Reports the approximate distance in time between two Time, Date or DateTime objects or integers as seconds.
|
|
29
|
+
# Reports the approximate distance in time between two Time, Date, or DateTime objects or integers as seconds.
|
|
30
30
|
# Pass <tt>include_seconds: true</tt> if you want more detailed approximations when distance < 1 min, 29 secs.
|
|
31
31
|
# Distances are reported based on the following table:
|
|
32
32
|
#
|
|
@@ -72,7 +72,7 @@ module ActionView
|
|
|
72
72
|
# distance_of_time_in_words(to_time, from_time, include_seconds: true) # => about 6 years
|
|
73
73
|
# distance_of_time_in_words(Time.now, Time.now) # => less than a minute
|
|
74
74
|
#
|
|
75
|
-
# With the <tt>scope</tt> option, you can define a custom scope for Rails
|
|
75
|
+
# With the <tt>scope</tt> option, you can define a custom scope for \Rails
|
|
76
76
|
# to look up the translation.
|
|
77
77
|
#
|
|
78
78
|
# For example you can define the following in your locale (e.g. en.yml).
|
|
@@ -140,7 +140,7 @@ module ActionView
|
|
|
140
140
|
minute_offset_for_leap_year = leap_years * 1440
|
|
141
141
|
# Discount the leap year days when calculating year distance.
|
|
142
142
|
# e.g. if there are 20 leap year days between 2 dates having the same day
|
|
143
|
-
# and month then
|
|
143
|
+
# and month then based on 365 days calculation
|
|
144
144
|
# the distance in years will come out to over 80 years when in written
|
|
145
145
|
# English it would read better as about 80 years.
|
|
146
146
|
minutes_with_offset = distance_in_minutes - minute_offset_for_leap_year
|
|
@@ -206,6 +206,7 @@ module ActionView
|
|
|
206
206
|
# you are creating new record. While editing existing record, <tt>:end_year</tt> defaults to
|
|
207
207
|
# the current selected year plus 5.
|
|
208
208
|
# * <tt>:year_format</tt> - Set format of years for year select. Lambda should be passed.
|
|
209
|
+
# * <tt>:day_format</tt> - Set format of days for day select. Lambda should be passed.
|
|
209
210
|
# * <tt>:discard_day</tt> - Set to true if you don't want to show a day select. This includes the day
|
|
210
211
|
# as a hidden field instead of showing a select field. Also note that this implicitly sets the day to be the
|
|
211
212
|
# first of the given month in order to not create invalid dates like 31 February.
|
|
@@ -216,7 +217,7 @@ module ActionView
|
|
|
216
217
|
# * <tt>:order</tt> - Set to an array containing <tt>:day</tt>, <tt>:month</tt> and <tt>:year</tt> to
|
|
217
218
|
# customize the order in which the select fields are shown. If you leave out any of the symbols, the respective
|
|
218
219
|
# select will not be shown (like when you set <tt>discard_xxx: true</tt>. Defaults to the order defined in
|
|
219
|
-
# the respective locale (e.g. [:year, :month, :day] in the en locale that ships with Rails).
|
|
220
|
+
# the respective locale (e.g. [:year, :month, :day] in the en locale that ships with \Rails).
|
|
220
221
|
# * <tt>:include_blank</tt> - Include a blank option in every select field so it's possible to set empty
|
|
221
222
|
# dates.
|
|
222
223
|
# * <tt>:default</tt> - Set a default date if the affected date isn't set or is +nil+.
|
|
@@ -279,6 +280,9 @@ module ActionView
|
|
|
279
280
|
# # Generates a date select with custom year format.
|
|
280
281
|
# date_select("article", "written_on", year_format: ->(year) { "Heisei #{year - 1988}" })
|
|
281
282
|
#
|
|
283
|
+
# # Generates a date select with custom day format.
|
|
284
|
+
# date_select("article", "written_on", day_format: ->(day) { day.ordinalize })
|
|
285
|
+
#
|
|
282
286
|
# The selects are prepared for multi-parameter assignment to an Active Record object.
|
|
283
287
|
#
|
|
284
288
|
# Note: If the day is not included as an option but the month is, the day will be set to the 1st to ensure that
|
|
@@ -287,12 +291,12 @@ module ActionView
|
|
|
287
291
|
Tags::DateSelect.new(object_name, method, self, options, html_options).render
|
|
288
292
|
end
|
|
289
293
|
|
|
290
|
-
# Returns a set of select tags (one for hour, minute and optionally second) pre-selected for accessing a
|
|
294
|
+
# Returns a set of select tags (one for hour, minute, and optionally second) pre-selected for accessing a
|
|
291
295
|
# specified time-based attribute (identified by +method+) on an object assigned to the template (identified by
|
|
292
296
|
# +object+). You can include the seconds with <tt>:include_seconds</tt>. You can get hours in the AM/PM format
|
|
293
297
|
# with <tt>:ampm</tt> option.
|
|
294
298
|
#
|
|
295
|
-
# This method will also generate 3 input hidden tags, for the actual year, month and day unless the option
|
|
299
|
+
# This method will also generate 3 input hidden tags, for the actual year, month, and day unless the option
|
|
296
300
|
# <tt>:ignore_date</tt> is set to +true+. If you set the <tt>:ignore_date</tt> to +true+, you must have a
|
|
297
301
|
# +date_select+ on the same method within the form otherwise an exception will be raised.
|
|
298
302
|
#
|
|
@@ -316,6 +320,10 @@ module ActionView
|
|
|
316
320
|
# # You can set :ampm option to true which will show the hours as: 12 PM, 01 AM .. 11 PM.
|
|
317
321
|
# time_select 'game', 'game_time', { ampm: true }
|
|
318
322
|
#
|
|
323
|
+
# # You can set :ignore_date option to true which will remove the hidden inputs for day,
|
|
324
|
+
# # month, and year that are set by default on this helper when you only want the time inputs
|
|
325
|
+
# time_select 'game', 'game_time', { ignore_date: true }
|
|
326
|
+
#
|
|
319
327
|
# The selects are prepared for multi-parameter assignment to an Active Record object.
|
|
320
328
|
#
|
|
321
329
|
# Note: If the day is not included as an option but the month is, the day will be set to the 1st to ensure that
|
|
@@ -699,7 +707,7 @@ module ActionView
|
|
|
699
707
|
end
|
|
700
708
|
end
|
|
701
709
|
|
|
702
|
-
class DateTimeSelector
|
|
710
|
+
class DateTimeSelector # :nodoc:
|
|
703
711
|
include ActionView::Helpers::TagHelper
|
|
704
712
|
|
|
705
713
|
DEFAULT_PREFIX = "date"
|
|
@@ -811,7 +819,7 @@ module ActionView
|
|
|
811
819
|
if @options[:use_hidden] || @options[:discard_day]
|
|
812
820
|
build_hidden(:day, day || 1)
|
|
813
821
|
else
|
|
814
|
-
|
|
822
|
+
build_select(:day, build_day_options(day))
|
|
815
823
|
end
|
|
816
824
|
end
|
|
817
825
|
|
|
@@ -840,14 +848,14 @@ module ActionView
|
|
|
840
848
|
if @options[:use_hidden] || @options[:discard_year]
|
|
841
849
|
build_hidden(:year, val)
|
|
842
850
|
else
|
|
843
|
-
options
|
|
844
|
-
options[:start]
|
|
845
|
-
options[:end]
|
|
846
|
-
options[:step]
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
if (options[:end] - options[:start]).abs >
|
|
851
|
+
options = {}
|
|
852
|
+
options[:start] = @options[:start_year] || middle_year - 5
|
|
853
|
+
options[:end] = @options[:end_year] || middle_year + 5
|
|
854
|
+
options[:step] = options[:start] < options[:end] ? 1 : -1
|
|
855
|
+
|
|
856
|
+
max_years_allowed = @options[:max_years_allowed] || 1000
|
|
857
|
+
|
|
858
|
+
if (options[:end] - options[:start]).abs > max_years_allowed
|
|
851
859
|
raise ArgumentError, "There are too many years options to be built. Are you sure you haven't mistyped something? You can provide the :max_years_allowed parameter."
|
|
852
860
|
end
|
|
853
861
|
|
|
@@ -867,6 +875,10 @@ module ActionView
|
|
|
867
875
|
end
|
|
868
876
|
end
|
|
869
877
|
|
|
878
|
+
def prompt_text(prompt, type)
|
|
879
|
+
prompt.kind_of?(String) ? prompt : I18n.translate(:"datetime.prompts.#{type}", locale: @options[:locale])
|
|
880
|
+
end
|
|
881
|
+
|
|
870
882
|
# If the day is hidden, the day should be set to the 1st so all month and year choices are
|
|
871
883
|
# valid. Otherwise, February 31st or February 29th, 2011 can be selected, which are invalid.
|
|
872
884
|
def set_day_if_discarded
|
|
@@ -880,7 +892,7 @@ module ActionView
|
|
|
880
892
|
def month_names
|
|
881
893
|
@month_names ||= begin
|
|
882
894
|
month_names = @options[:use_month_names] || translated_month_names
|
|
883
|
-
month_names
|
|
895
|
+
month_names = [nil, *month_names] if month_names.size < 13
|
|
884
896
|
month_names
|
|
885
897
|
end
|
|
886
898
|
end
|
|
@@ -899,6 +911,27 @@ module ActionView
|
|
|
899
911
|
I18n.translate(key, locale: @options[:locale])
|
|
900
912
|
end
|
|
901
913
|
|
|
914
|
+
# Looks up day names by number.
|
|
915
|
+
#
|
|
916
|
+
# day_name(1) # => 1
|
|
917
|
+
#
|
|
918
|
+
# If the <tt>use_two_digit_numbers: true</tt> option is passed to DateTimeSelector:
|
|
919
|
+
#
|
|
920
|
+
# day_name(1) # => "01"
|
|
921
|
+
#
|
|
922
|
+
# If the <tt>day_format: ->(day) { day.ordinalize }</tt> option is passed to DateTimeSelector:
|
|
923
|
+
#
|
|
924
|
+
# day_name(1) # => "1st"
|
|
925
|
+
def day_name(number)
|
|
926
|
+
if day_format_lambda = @options[:day_format]
|
|
927
|
+
day_format_lambda.call(number)
|
|
928
|
+
elsif @options[:use_two_digit_numbers]
|
|
929
|
+
"%02d" % number
|
|
930
|
+
else
|
|
931
|
+
number
|
|
932
|
+
end
|
|
933
|
+
end
|
|
934
|
+
|
|
902
935
|
# Looks up month names by number (1-based):
|
|
903
936
|
#
|
|
904
937
|
# month_name(1) # => "January"
|
|
@@ -907,7 +940,7 @@ module ActionView
|
|
|
907
940
|
#
|
|
908
941
|
# month_name(1) # => 1
|
|
909
942
|
#
|
|
910
|
-
# If the <tt>:
|
|
943
|
+
# If the <tt>:use_two_digit_numbers</tt> option is passed:
|
|
911
944
|
#
|
|
912
945
|
# month_name(1) # => '01'
|
|
913
946
|
#
|
|
@@ -972,22 +1005,25 @@ module ActionView
|
|
|
972
1005
|
end
|
|
973
1006
|
|
|
974
1007
|
# Build select option HTML from date value and options.
|
|
975
|
-
# build_options(15, start: 1, end: 31)
|
|
976
|
-
# => "<option value="1">1</option>
|
|
977
|
-
# <option value="2">2</option>
|
|
978
|
-
# <option value="3">3</option>..."
|
|
979
1008
|
#
|
|
980
|
-
#
|
|
981
|
-
#
|
|
982
|
-
#
|
|
983
|
-
#
|
|
984
|
-
#
|
|
1009
|
+
# build_options(15, start: 1, end: 31)
|
|
1010
|
+
# => "<option value="1">1</option>
|
|
1011
|
+
# <option value="2">2</option>
|
|
1012
|
+
# <option value="3">3</option>..."
|
|
1013
|
+
#
|
|
1014
|
+
# If <tt>use_two_digit_numbers: true</tt> option is passed:
|
|
985
1015
|
#
|
|
986
|
-
#
|
|
987
|
-
#
|
|
988
|
-
#
|
|
989
|
-
#
|
|
990
|
-
#
|
|
1016
|
+
# build_options(15, start: 1, end: 31, use_two_digit_numbers: true)
|
|
1017
|
+
# => "<option value="1">01</option>
|
|
1018
|
+
# <option value="2">02</option>
|
|
1019
|
+
# <option value="3">03</option>..."
|
|
1020
|
+
#
|
|
1021
|
+
# If <tt>:step</tt> options is passed:
|
|
1022
|
+
#
|
|
1023
|
+
# build_options(15, start: 1, end: 31, step: 2)
|
|
1024
|
+
# => "<option value="1">1</option>
|
|
1025
|
+
# <option value="3">3</option>
|
|
1026
|
+
# <option value="5">5</option>..."
|
|
991
1027
|
def build_options(selected, options = {})
|
|
992
1028
|
options = {
|
|
993
1029
|
leading_zeros: true, ampm: false, use_two_digit_numbers: false
|
|
@@ -1011,18 +1047,44 @@ module ActionView
|
|
|
1011
1047
|
(select_options.join("\n") + "\n").html_safe
|
|
1012
1048
|
end
|
|
1013
1049
|
|
|
1050
|
+
# Build select option HTML for day.
|
|
1051
|
+
#
|
|
1052
|
+
# build_day_options(2)
|
|
1053
|
+
# => "<option value="1">1</option>
|
|
1054
|
+
# <option value="2" selected="selected">2</option>
|
|
1055
|
+
# <option value="3">3</option>..."
|
|
1056
|
+
#
|
|
1057
|
+
# If <tt>day_format: ->(day) { day.ordinalize }</tt> option is passed to DateTimeSelector
|
|
1058
|
+
#
|
|
1059
|
+
# build_day_options(2)
|
|
1060
|
+
# => "<option value="1">1st</option>
|
|
1061
|
+
# <option value="2" selected="selected">2nd</option>
|
|
1062
|
+
# <option value="3">3rd</option>..."
|
|
1063
|
+
#
|
|
1064
|
+
# If <tt>use_two_digit_numbers: true</tt> option is passed to DateTimeSelector
|
|
1065
|
+
#
|
|
1066
|
+
# build_day_options(2)
|
|
1067
|
+
# => "<option value="1">01</option>
|
|
1068
|
+
# <option value="2" selected="selected">02</option>
|
|
1069
|
+
# <option value="3">03</option>..."
|
|
1070
|
+
def build_day_options(selected)
|
|
1071
|
+
select_options = []
|
|
1072
|
+
(1..31).each do |value|
|
|
1073
|
+
tag_options = { value: value }
|
|
1074
|
+
tag_options[:selected] = "selected" if selected == value
|
|
1075
|
+
text = day_name(value)
|
|
1076
|
+
select_options << content_tag("option", text, tag_options)
|
|
1077
|
+
end
|
|
1078
|
+
|
|
1079
|
+
(select_options.join("\n") + "\n").html_safe
|
|
1080
|
+
end
|
|
1081
|
+
|
|
1014
1082
|
# Build select option HTML for year.
|
|
1015
|
-
# If <tt>year_format</tt> option is not passed
|
|
1016
|
-
# build_year_options(1998, start: 1998, end: 2000)
|
|
1017
|
-
# => "<option value="1998" selected="selected">1998</option>
|
|
1018
|
-
# <option value="1999">1999</option>
|
|
1019
|
-
# <option value="2000">2000</option>"
|
|
1020
1083
|
#
|
|
1021
|
-
#
|
|
1022
|
-
#
|
|
1023
|
-
#
|
|
1024
|
-
#
|
|
1025
|
-
# <option value="2000">Heisei 12</option>"
|
|
1084
|
+
# build_year_options(1998, start: 1998, end: 2000)
|
|
1085
|
+
# => "<option value="1998" selected="selected">1998</option>
|
|
1086
|
+
# <option value="1999">1999</option>
|
|
1087
|
+
# <option value="2000">2000</option>"
|
|
1026
1088
|
def build_year_options(selected, options = {})
|
|
1027
1089
|
start = options.delete(:start)
|
|
1028
1090
|
stop = options.delete(:end)
|
|
@@ -1040,10 +1102,11 @@ module ActionView
|
|
|
1040
1102
|
end
|
|
1041
1103
|
|
|
1042
1104
|
# Builds select tag from date type and HTML select options.
|
|
1043
|
-
#
|
|
1044
|
-
#
|
|
1045
|
-
#
|
|
1046
|
-
#
|
|
1105
|
+
#
|
|
1106
|
+
# build_select(:month, "<option value="1">January</option>...")
|
|
1107
|
+
# => "<select id="post_written_on_2i" name="post[written_on(2i)]">
|
|
1108
|
+
# <option value="1">January</option>...
|
|
1109
|
+
# </select>"
|
|
1047
1110
|
def build_select(type, select_options_as_html)
|
|
1048
1111
|
select_options = {
|
|
1049
1112
|
id: input_id_from_type(type),
|
|
@@ -1060,9 +1123,10 @@ module ActionView
|
|
|
1060
1123
|
(content_tag("select", select_html.html_safe, select_options) + "\n").html_safe
|
|
1061
1124
|
end
|
|
1062
1125
|
|
|
1063
|
-
# Builds the
|
|
1064
|
-
#
|
|
1065
|
-
#
|
|
1126
|
+
# Builds the CSS class value for the select element.
|
|
1127
|
+
#
|
|
1128
|
+
# css_class_attribute(:year, 'date optional', { year: 'my-year' })
|
|
1129
|
+
# => "date optional my-year"
|
|
1066
1130
|
def css_class_attribute(type, html_options_class, options) # :nodoc:
|
|
1067
1131
|
css_class = \
|
|
1068
1132
|
case options
|
|
@@ -1076,8 +1140,9 @@ module ActionView
|
|
|
1076
1140
|
end
|
|
1077
1141
|
|
|
1078
1142
|
# Builds a prompt option tag with supplied options or from default options.
|
|
1079
|
-
#
|
|
1080
|
-
#
|
|
1143
|
+
#
|
|
1144
|
+
# prompt_option_tag(:month, prompt: 'Select month')
|
|
1145
|
+
# => "<option value="">Select month</option>"
|
|
1081
1146
|
def prompt_option_tag(type, options)
|
|
1082
1147
|
prompt = \
|
|
1083
1148
|
case options
|
|
@@ -1090,12 +1155,13 @@ module ActionView
|
|
|
1090
1155
|
I18n.translate(:"datetime.prompts.#{type}", locale: @options[:locale])
|
|
1091
1156
|
end
|
|
1092
1157
|
|
|
1093
|
-
prompt ? content_tag("option", prompt, value: "") : ""
|
|
1158
|
+
prompt ? content_tag("option", prompt_text(prompt, type), value: "") : ""
|
|
1094
1159
|
end
|
|
1095
1160
|
|
|
1096
1161
|
# Builds hidden input tag for date part and value.
|
|
1097
|
-
#
|
|
1098
|
-
#
|
|
1162
|
+
#
|
|
1163
|
+
# build_hidden(:year, 2008)
|
|
1164
|
+
# => "<input type="hidden" id="date_year" name="date[year]" value="2008" autocomplete="off" />"
|
|
1099
1165
|
def build_hidden(type, value)
|
|
1100
1166
|
select_options = {
|
|
1101
1167
|
type: "hidden",
|
|
@@ -1126,7 +1192,7 @@ module ActionView
|
|
|
1126
1192
|
# Returns the id attribute for the input tag.
|
|
1127
1193
|
# => "post_written_on_1i"
|
|
1128
1194
|
def input_id_from_type(type)
|
|
1129
|
-
id = input_name_from_type(type).gsub(/([\[
|
|
1195
|
+
id = input_name_from_type(type).gsub(/([\[(])|(\]\[)/, "_").gsub(/[\])]/, "")
|
|
1130
1196
|
id = @options[:namespace] + "_" + id if @options[:namespace]
|
|
1131
1197
|
|
|
1132
1198
|
id
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require "action_view/helpers/tag_helper"
|
|
4
|
+
|
|
3
5
|
module ActionView
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
module Helpers # :nodoc:
|
|
7
|
+
# = Action View Debug \Helpers
|
|
8
|
+
#
|
|
9
|
+
# Provides a set of methods for making it easier to debug \Rails objects.
|
|
8
10
|
module DebugHelper
|
|
9
11
|
include TagHelper
|
|
10
12
|
|