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
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require "action_view/helpers/tag_helper"
|
|
4
|
-
require "active_support/
|
|
4
|
+
require "active_support/html_safe_translation"
|
|
5
5
|
|
|
6
6
|
module ActionView
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
module Helpers # :nodoc:
|
|
8
|
+
# = Action View Translation \Helpers
|
|
9
9
|
module TranslationHelper
|
|
10
10
|
extend ActiveSupport::Concern
|
|
11
11
|
|
|
12
12
|
include TagHelper
|
|
13
13
|
|
|
14
|
+
# Specify whether an error should be raised for missing translations.
|
|
15
|
+
singleton_class.attr_accessor :raise_on_missing_translations
|
|
16
|
+
|
|
14
17
|
included do
|
|
15
18
|
mattr_accessor :debug_missing_translation, default: true
|
|
16
19
|
end
|
|
@@ -37,7 +40,7 @@ module ActionView
|
|
|
37
40
|
#
|
|
38
41
|
# If you would prefer missing translations to raise an error, you can
|
|
39
42
|
# opt out of span-wrapping behavior globally by setting
|
|
40
|
-
# <tt>
|
|
43
|
+
# <tt>config.i18n.raise_on_missing_translations = true</tt> or
|
|
41
44
|
# individually by passing <tt>raise: true</tt> as an option to
|
|
42
45
|
# <tt>translate</tt>.
|
|
43
46
|
#
|
|
@@ -75,7 +78,7 @@ module ActionView
|
|
|
75
78
|
options[:default].is_a?(Array) ? options.delete(:default).compact : [options.delete(:default)]
|
|
76
79
|
end
|
|
77
80
|
|
|
78
|
-
options[:raise] = true if options[:raise].nil? &&
|
|
81
|
+
options[:raise] = true if options[:raise].nil? && TranslationHelper.raise_on_missing_translations
|
|
79
82
|
default = MISSING_TRANSLATION
|
|
80
83
|
|
|
81
84
|
translation = while key || alternatives.present?
|
|
@@ -85,17 +88,12 @@ module ActionView
|
|
|
85
88
|
|
|
86
89
|
key = scope_key_by_partial(key)
|
|
87
90
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
break html_safe_translation(translated) unless translated.equal?(MISSING_TRANSLATION)
|
|
92
|
-
else
|
|
93
|
-
translated = I18n.translate(key, **options, default: default)
|
|
94
|
-
break translated unless translated.equal?(MISSING_TRANSLATION)
|
|
95
|
-
end
|
|
91
|
+
translated = ActiveSupport::HtmlSafeTranslation.translate(key, **options, default: default)
|
|
92
|
+
|
|
93
|
+
break translated unless translated == MISSING_TRANSLATION
|
|
96
94
|
|
|
97
95
|
if alternatives.present? && !alternatives.first.is_a?(Symbol)
|
|
98
|
-
break alternatives.first && I18n.translate(**options, default: alternatives)
|
|
96
|
+
break alternatives.first && I18n.translate(nil, **options, default: alternatives)
|
|
99
97
|
end
|
|
100
98
|
|
|
101
99
|
first_key ||= key
|
|
@@ -113,7 +111,7 @@ module ActionView
|
|
|
113
111
|
|
|
114
112
|
# Delegates to <tt>I18n.localize</tt> with no additional functionality.
|
|
115
113
|
#
|
|
116
|
-
# See https://www.rubydoc.info/
|
|
114
|
+
# See https://www.rubydoc.info/gems/i18n/I18n/Backend/Base:localize
|
|
117
115
|
# for more information.
|
|
118
116
|
def localize(object, **options)
|
|
119
117
|
I18n.localize(object, **options)
|
|
@@ -121,16 +119,12 @@ module ActionView
|
|
|
121
119
|
alias :l :localize
|
|
122
120
|
|
|
123
121
|
private
|
|
124
|
-
MISSING_TRANSLATION =
|
|
122
|
+
MISSING_TRANSLATION = -(2**60)
|
|
125
123
|
private_constant :MISSING_TRANSLATION
|
|
126
124
|
|
|
127
125
|
NO_DEFAULT = [].freeze
|
|
128
126
|
private_constant :NO_DEFAULT
|
|
129
127
|
|
|
130
|
-
def self.i18n_option?(name)
|
|
131
|
-
(@i18n_option_names ||= I18n::RESERVED_KEYS.to_set).include?(name)
|
|
132
|
-
end
|
|
133
|
-
|
|
134
128
|
def scope_key_by_partial(key)
|
|
135
129
|
if key&.start_with?(".")
|
|
136
130
|
if @virtual_path
|
|
@@ -145,31 +139,6 @@ module ActionView
|
|
|
145
139
|
end
|
|
146
140
|
end
|
|
147
141
|
|
|
148
|
-
def html_escape_translation_options(options)
|
|
149
|
-
return options if options.empty?
|
|
150
|
-
html_safe_options = options.dup
|
|
151
|
-
|
|
152
|
-
options.each do |name, value|
|
|
153
|
-
unless TranslationHelper.i18n_option?(name) || (name == :count && value.is_a?(Numeric))
|
|
154
|
-
html_safe_options[name] = ERB::Util.html_escape(value.to_s)
|
|
155
|
-
end
|
|
156
|
-
end
|
|
157
|
-
|
|
158
|
-
html_safe_options
|
|
159
|
-
end
|
|
160
|
-
|
|
161
|
-
def html_safe_translation_key?(key)
|
|
162
|
-
/(?:_|\b)html\z/.match?(key)
|
|
163
|
-
end
|
|
164
|
-
|
|
165
|
-
def html_safe_translation(translation)
|
|
166
|
-
if translation.respond_to?(:map)
|
|
167
|
-
translation.map { |element| element.respond_to?(:html_safe) ? element.html_safe : element }
|
|
168
|
-
else
|
|
169
|
-
translation.respond_to?(:html_safe) ? translation.html_safe : translation
|
|
170
|
-
end
|
|
171
|
-
end
|
|
172
|
-
|
|
173
142
|
def missing_translation(key, options)
|
|
174
143
|
keys = I18n.normalize_keys(options[:locale] || I18n.locale, key, options[:scope])
|
|
175
144
|
|