actionview 6.0.0.rc1 → 6.0.3.rc1
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +62 -0
- data/README.rdoc +1 -1
- data/lib/action_view.rb +1 -0
- data/lib/action_view/base.rb +1 -1
- data/lib/action_view/cache_expiry.rb +13 -9
- data/lib/action_view/digestor.rb +5 -4
- data/lib/action_view/flows.rb +0 -1
- data/lib/action_view/gem_version.rb +1 -1
- data/lib/action_view/helpers/active_model_helper.rb +0 -1
- data/lib/action_view/helpers/asset_tag_helper.rb +1 -1
- data/lib/action_view/helpers/cache_helper.rb +1 -2
- data/lib/action_view/helpers/date_helper.rb +1 -2
- data/lib/action_view/helpers/form_helper.rb +2 -2
- data/lib/action_view/helpers/form_options_helper.rb +4 -3
- data/lib/action_view/helpers/form_tag_helper.rb +4 -1
- data/lib/action_view/helpers/javascript_helper.rb +4 -2
- data/lib/action_view/helpers/number_helper.rb +3 -2
- data/lib/action_view/helpers/sanitize_helper.rb +10 -16
- data/lib/action_view/helpers/tag_helper.rb +3 -3
- data/lib/action_view/helpers/tags/base.rb +0 -1
- data/lib/action_view/helpers/tags/check_box.rb +0 -1
- data/lib/action_view/helpers/tags/collection_check_boxes.rb +0 -1
- data/lib/action_view/helpers/tags/collection_helpers.rb +0 -1
- data/lib/action_view/helpers/tags/collection_radio_buttons.rb +0 -1
- data/lib/action_view/helpers/tags/color_field.rb +0 -1
- data/lib/action_view/helpers/tags/date_field.rb +0 -1
- data/lib/action_view/helpers/tags/date_select.rb +0 -1
- data/lib/action_view/helpers/tags/datetime_field.rb +0 -1
- data/lib/action_view/helpers/tags/datetime_local_field.rb +0 -1
- data/lib/action_view/helpers/tags/label.rb +0 -1
- data/lib/action_view/helpers/tags/month_field.rb +0 -1
- data/lib/action_view/helpers/tags/radio_button.rb +0 -1
- data/lib/action_view/helpers/tags/select.rb +0 -1
- data/lib/action_view/helpers/tags/text_field.rb +0 -1
- data/lib/action_view/helpers/tags/time_field.rb +0 -1
- data/lib/action_view/helpers/tags/week_field.rb +0 -1
- data/lib/action_view/helpers/text_helper.rb +0 -1
- data/lib/action_view/helpers/translation_helper.rb +7 -8
- data/lib/action_view/helpers/url_helper.rb +1 -1
- data/lib/action_view/layouts.rb +0 -3
- data/lib/action_view/log_subscriber.rb +0 -1
- data/lib/action_view/lookup_context.rb +4 -3
- data/lib/action_view/path_set.rb +0 -1
- data/lib/action_view/record_identifier.rb +0 -1
- data/lib/action_view/renderer/abstract_renderer.rb +0 -1
- data/lib/action_view/renderer/partial_renderer.rb +0 -4
- data/lib/action_view/renderer/partial_renderer/collection_caching.rb +1 -1
- data/lib/action_view/renderer/streaming_template_renderer.rb +0 -2
- data/lib/action_view/renderer/template_renderer.rb +1 -2
- data/lib/action_view/rendering.rb +0 -1
- data/lib/action_view/template.rb +0 -1
- data/lib/action_view/template/error.rb +9 -14
- data/lib/action_view/template/handlers/erb.rb +0 -1
- data/lib/action_view/template/resolver.rb +1 -5
- data/lib/action_view/test_case.rb +2 -3
- data/lib/action_view/testing/resolvers.rb +25 -14
- data/lib/action_view/unbound_template.rb +1 -2
- data/lib/action_view/view_paths.rb +0 -1
- data/lib/assets/compiled/rails-ujs.js +7 -4
- metadata +18 -15
@@ -57,10 +57,9 @@ module ActionView
|
|
57
57
|
# that include HTML tags so that you know what kind of output to expect
|
58
58
|
# when you call translate in a template and translators know which keys
|
59
59
|
# they can provide HTML values for.
|
60
|
-
def translate(key, options
|
61
|
-
options = options.dup
|
60
|
+
def translate(key, **options)
|
62
61
|
if options.has_key?(:default)
|
63
|
-
remaining_defaults = Array(options.delete(:default)).compact
|
62
|
+
remaining_defaults = Array.wrap(options.delete(:default)).compact
|
64
63
|
options[:default] = remaining_defaults unless remaining_defaults.first.kind_of?(Symbol)
|
65
64
|
end
|
66
65
|
|
@@ -82,18 +81,18 @@ module ActionView
|
|
82
81
|
html_safe_options[name] = ERB::Util.html_escape(value.to_s)
|
83
82
|
end
|
84
83
|
end
|
85
|
-
translation = I18n.translate(scope_key_by_partial(key), html_safe_options.merge(raise: i18n_raise))
|
84
|
+
translation = I18n.translate(scope_key_by_partial(key), **html_safe_options.merge(raise: i18n_raise))
|
86
85
|
if translation.respond_to?(:map)
|
87
86
|
translation.map { |element| element.respond_to?(:html_safe) ? element.html_safe : element }
|
88
87
|
else
|
89
88
|
translation.respond_to?(:html_safe) ? translation.html_safe : translation
|
90
89
|
end
|
91
90
|
else
|
92
|
-
I18n.translate(scope_key_by_partial(key), options.merge(raise: i18n_raise))
|
91
|
+
I18n.translate(scope_key_by_partial(key), **options.merge(raise: i18n_raise))
|
93
92
|
end
|
94
93
|
rescue I18n::MissingTranslationData => e
|
95
94
|
if remaining_defaults.present?
|
96
|
-
translate remaining_defaults.shift, options.merge(default: remaining_defaults)
|
95
|
+
translate remaining_defaults.shift, **options.merge(default: remaining_defaults)
|
97
96
|
else
|
98
97
|
raise e if raise_error
|
99
98
|
|
@@ -116,8 +115,8 @@ module ActionView
|
|
116
115
|
#
|
117
116
|
# See https://www.rubydoc.info/github/svenfuchs/i18n/master/I18n/Backend/Base:localize
|
118
117
|
# for more information.
|
119
|
-
def localize(
|
120
|
-
I18n.localize(
|
118
|
+
def localize(object, **options)
|
119
|
+
I18n.localize(object, **options)
|
121
120
|
end
|
122
121
|
alias :l :localize
|
123
122
|
|
@@ -253,7 +253,7 @@ module ActionView
|
|
253
253
|
# # <input value="New" type="submit" />
|
254
254
|
# # </form>"
|
255
255
|
#
|
256
|
-
# <%= button_to "New",
|
256
|
+
# <%= button_to "New", new_article_path %>
|
257
257
|
# # => "<form method="post" action="/articles/new" class="button_to">
|
258
258
|
# # <input value="New" type="submit" />
|
259
259
|
# # </form>"
|
data/lib/action_view/layouts.rb
CHANGED
@@ -224,7 +224,6 @@ module ActionView
|
|
224
224
|
# that if no layout conditions are used, this method is not used
|
225
225
|
module LayoutConditions # :nodoc:
|
226
226
|
private
|
227
|
-
|
228
227
|
# Determines whether the current action has a layout definition by
|
229
228
|
# checking the action name against the :only and :except conditions
|
230
229
|
# set by the <tt>layout</tt> method.
|
@@ -334,7 +333,6 @@ module ActionView
|
|
334
333
|
end
|
335
334
|
|
336
335
|
private
|
337
|
-
|
338
336
|
# If no layout is supplied, look for a template named the return
|
339
337
|
# value of this method.
|
340
338
|
#
|
@@ -372,7 +370,6 @@ module ActionView
|
|
372
370
|
end
|
373
371
|
|
374
372
|
private
|
375
|
-
|
376
373
|
def _conditional_layout?
|
377
374
|
true
|
378
375
|
end
|
@@ -61,6 +61,7 @@ module ActionView
|
|
61
61
|
|
62
62
|
@details_keys = Concurrent::Map.new
|
63
63
|
@digest_cache = Concurrent::Map.new
|
64
|
+
@view_context_mutex = Mutex.new
|
64
65
|
|
65
66
|
def self.digest_cache(details)
|
66
67
|
@digest_cache[details_cache_key(details)] ||= Concurrent::Map.new
|
@@ -89,7 +90,9 @@ module ActionView
|
|
89
90
|
end
|
90
91
|
|
91
92
|
def self.view_context_class(klass)
|
92
|
-
@
|
93
|
+
@view_context_mutex.synchronize do
|
94
|
+
@view_context_class ||= klass.with_empty_template_cache
|
95
|
+
end
|
93
96
|
end
|
94
97
|
end
|
95
98
|
|
@@ -112,7 +115,6 @@ module ActionView
|
|
112
115
|
end
|
113
116
|
|
114
117
|
private
|
115
|
-
|
116
118
|
def _set_detail(key, value) # :doc:
|
117
119
|
@details = @details.dup if @digest_cache || @details_key
|
118
120
|
@digest_cache = nil
|
@@ -171,7 +173,6 @@ module ActionView
|
|
171
173
|
end
|
172
174
|
|
173
175
|
private
|
174
|
-
|
175
176
|
# Whenever setting view paths, makes a copy so that we can manipulate them in
|
176
177
|
# instance objects as we wish.
|
177
178
|
def build_view_paths(paths)
|
data/lib/action_view/path_set.rb
CHANGED
@@ -95,7 +95,6 @@ module ActionView
|
|
95
95
|
end
|
96
96
|
|
97
97
|
private
|
98
|
-
|
99
98
|
# Returns a string representation of the key attribute(s) that is suitable for use in an HTML DOM id.
|
100
99
|
# This can be overwritten to customize the default generated string representation if desired.
|
101
100
|
# If you need to read back a key from a dom_id in order to query for the underlying database record,
|
@@ -105,9 +105,6 @@ module ActionView
|
|
105
105
|
#
|
106
106
|
# <%= render(partial: "ad", collection: @advertisements) || "There's no ad to be displayed" %>
|
107
107
|
#
|
108
|
-
# NOTE: Due to backwards compatibility concerns, the collection can't be one of hashes. Normally you'd also
|
109
|
-
# just keep domain objects, like Active Records, in there.
|
110
|
-
#
|
111
108
|
# == \Rendering shared partials
|
112
109
|
#
|
113
110
|
# Two controllers can share a set of partials and render them like this:
|
@@ -322,7 +319,6 @@ module ActionView
|
|
322
319
|
end
|
323
320
|
|
324
321
|
private
|
325
|
-
|
326
322
|
def render_collection(view, template)
|
327
323
|
identifier = (template && template.identifier) || @path
|
328
324
|
instrument(:collection, identifier: identifier, count: @collection.size) do |payload|
|
@@ -12,7 +12,7 @@ module ActionView
|
|
12
12
|
|
13
13
|
private
|
14
14
|
def cache_collection_render(instrumentation_payload, view, template)
|
15
|
-
return yield unless @options[:cached]
|
15
|
+
return yield unless @options[:cached] && view.controller.respond_to?(:perform_caching) && view.controller.perform_caching
|
16
16
|
|
17
17
|
# Result is a hash with the key represents the
|
18
18
|
# key used for cache lookup and the value is the item
|
@@ -27,7 +27,6 @@ module ActionView
|
|
27
27
|
end
|
28
28
|
|
29
29
|
private
|
30
|
-
|
31
30
|
# This is the same logging logic as in ShowExceptions middleware.
|
32
31
|
def log_error(exception)
|
33
32
|
logger = ActionView::Base.logger
|
@@ -55,7 +54,6 @@ module ActionView
|
|
55
54
|
end
|
56
55
|
|
57
56
|
private
|
58
|
-
|
59
57
|
def delayed_render(buffer, template, layout, view, locals)
|
60
58
|
# Wrap the given buffer in the StreamingBuffer and pass it to the
|
61
59
|
# underlying template handler. Now, every time something is concatenated
|
@@ -14,7 +14,6 @@ module ActionView
|
|
14
14
|
end
|
15
15
|
|
16
16
|
private
|
17
|
-
|
18
17
|
# Determine the template to be rendered using the given options.
|
19
18
|
def determine_template(options)
|
20
19
|
keys = options.has_key?(:locals) ? options[:locals].keys : []
|
@@ -96,7 +95,7 @@ module ActionView
|
|
96
95
|
end
|
97
96
|
rescue ActionView::MissingTemplate
|
98
97
|
all_details = @details.merge(formats: @lookup_context.default_formats)
|
99
|
-
raise unless template_exists?(layout, nil, false, [], all_details)
|
98
|
+
raise unless template_exists?(layout, nil, false, [], **all_details)
|
100
99
|
end
|
101
100
|
when Proc
|
102
101
|
resolve_layout(layout.call(@lookup_context, formats), keys, formats)
|
data/lib/action_view/template.rb
CHANGED
@@ -81,19 +81,19 @@ module ActionView
|
|
81
81
|
end
|
82
82
|
end
|
83
83
|
|
84
|
-
def source_extract(indentation = 0
|
85
|
-
return unless num = line_number
|
84
|
+
def source_extract(indentation = 0)
|
85
|
+
return [] unless num = line_number
|
86
86
|
num = num.to_i
|
87
87
|
|
88
|
-
source_code = @template.
|
88
|
+
source_code = @template.encode!.split("\n")
|
89
89
|
|
90
90
|
start_on_line = [ num - SOURCE_CODE_RADIUS - 1, 0 ].max
|
91
91
|
end_on_line = [ num + SOURCE_CODE_RADIUS - 1, source_code.length].min
|
92
92
|
|
93
93
|
indent = end_on_line.to_s.size + indentation
|
94
|
-
return unless source_code = source_code[start_on_line..end_on_line]
|
94
|
+
return [] unless source_code = source_code[start_on_line..end_on_line]
|
95
95
|
|
96
|
-
formatted_code_for(source_code, start_on_line, indent
|
96
|
+
formatted_code_for(source_code, start_on_line, indent)
|
97
97
|
end
|
98
98
|
|
99
99
|
def sub_template_of(template_path)
|
@@ -114,7 +114,6 @@ module ActionView
|
|
114
114
|
end
|
115
115
|
|
116
116
|
private
|
117
|
-
|
118
117
|
def source_location
|
119
118
|
if line_number
|
120
119
|
"on line ##{line_number} of "
|
@@ -123,15 +122,11 @@ module ActionView
|
|
123
122
|
end + file_name
|
124
123
|
end
|
125
124
|
|
126
|
-
def formatted_code_for(source_code, line_counter, indent
|
127
|
-
|
128
|
-
source_code.
|
125
|
+
def formatted_code_for(source_code, line_counter, indent)
|
126
|
+
indent_template = "%#{indent}s: %s"
|
127
|
+
source_code.map do |line|
|
129
128
|
line_counter += 1
|
130
|
-
|
131
|
-
result.update(line_counter.to_s => "%#{indent}s %s\n" % ["", line])
|
132
|
-
else
|
133
|
-
result << "%#{indent}s: %s" % [line_counter, line]
|
134
|
-
end
|
129
|
+
indent_template % [line_counter, line]
|
135
130
|
end
|
136
131
|
end
|
137
132
|
end
|
@@ -93,7 +93,6 @@ module ActionView
|
|
93
93
|
end
|
94
94
|
|
95
95
|
private
|
96
|
-
|
97
96
|
def canonical_no_templates(templates)
|
98
97
|
templates.empty? ? NO_TEMPLATES : templates
|
99
98
|
end
|
@@ -130,7 +129,6 @@ module ActionView
|
|
130
129
|
end
|
131
130
|
|
132
131
|
private
|
133
|
-
|
134
132
|
def _find_all(name, prefix, partial, details, key, locals)
|
135
133
|
find_templates(name, prefix, partial, details, locals)
|
136
134
|
end
|
@@ -183,7 +181,6 @@ module ActionView
|
|
183
181
|
end
|
184
182
|
|
185
183
|
private
|
186
|
-
|
187
184
|
def _find_all(name, prefix, partial, details, key, locals)
|
188
185
|
path = Path.build(name, prefix, partial)
|
189
186
|
query(path, details, details[:formats], locals, cache: !!key)
|
@@ -323,7 +320,6 @@ module ActionView
|
|
323
320
|
end
|
324
321
|
|
325
322
|
private
|
326
|
-
|
327
323
|
def find_template_paths_from_details(path, details)
|
328
324
|
# Instead of checking for every possible path, as our other globs would
|
329
325
|
# do, scan the directory for files with the right prefix.
|
@@ -358,7 +354,7 @@ module ActionView
|
|
358
354
|
end
|
359
355
|
|
360
356
|
def build_regex(path, details)
|
361
|
-
query =
|
357
|
+
query = Regexp.escape(File.join(@path, path))
|
362
358
|
exts = EXTENSIONS.map do |ext, prefix|
|
363
359
|
match =
|
364
360
|
if ext == :variants && details[ext] == :any
|