actionview 5.1.7 → 5.2.8.1
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 +119 -178
- data/MIT-LICENSE +1 -1
- data/README.rdoc +4 -4
- data/lib/action_view/base.rb +8 -10
- data/lib/action_view/buffers.rb +2 -0
- data/lib/action_view/context.rb +2 -2
- data/lib/action_view/dependency_tracker.rb +2 -0
- data/lib/action_view/digestor.rb +7 -7
- data/lib/action_view/flows.rb +2 -0
- data/lib/action_view/gem_version.rb +5 -3
- data/lib/action_view/helpers/active_model_helper.rb +9 -3
- data/lib/action_view/helpers/asset_tag_helper.rb +180 -34
- data/lib/action_view/helpers/asset_url_helper.rb +19 -17
- data/lib/action_view/helpers/atom_feed_helper.rb +3 -1
- data/lib/action_view/helpers/cache_helper.rb +24 -14
- data/lib/action_view/helpers/capture_helper.rb +9 -7
- data/lib/action_view/helpers/controller_helper.rb +3 -1
- data/lib/action_view/helpers/csp_helper.rb +24 -0
- data/lib/action_view/helpers/csrf_helper.rb +4 -2
- data/lib/action_view/helpers/date_helper.rb +7 -5
- data/lib/action_view/helpers/debug_helper.rb +4 -2
- data/lib/action_view/helpers/form_helper.rb +53 -70
- data/lib/action_view/helpers/form_options_helper.rb +23 -17
- data/lib/action_view/helpers/form_tag_helper.rb +23 -11
- data/lib/action_view/helpers/javascript_helper.rb +20 -5
- data/lib/action_view/helpers/number_helper.rb +2 -0
- data/lib/action_view/helpers/output_safety_helper.rb +2 -0
- data/lib/action_view/helpers/record_tag_helper.rb +3 -1
- data/lib/action_view/helpers/rendering_helper.rb +3 -1
- data/lib/action_view/helpers/sanitize_helper.rb +3 -1
- data/lib/action_view/helpers/tag_helper.rb +39 -8
- data/lib/action_view/helpers/tags/base.rb +12 -10
- data/lib/action_view/helpers/tags/check_box.rb +3 -1
- data/lib/action_view/helpers/tags/checkable.rb +4 -2
- data/lib/action_view/helpers/tags/collection_check_boxes.rb +2 -0
- data/lib/action_view/helpers/tags/collection_helpers.rb +2 -0
- data/lib/action_view/helpers/tags/collection_radio_buttons.rb +2 -0
- data/lib/action_view/helpers/tags/collection_select.rb +3 -1
- data/lib/action_view/helpers/tags/color_field.rb +3 -1
- data/lib/action_view/helpers/tags/date_field.rb +2 -0
- data/lib/action_view/helpers/tags/date_select.rb +3 -1
- data/lib/action_view/helpers/tags/datetime_field.rb +3 -1
- data/lib/action_view/helpers/tags/datetime_local_field.rb +2 -0
- data/lib/action_view/helpers/tags/datetime_select.rb +2 -0
- data/lib/action_view/helpers/tags/email_field.rb +2 -0
- data/lib/action_view/helpers/tags/file_field.rb +2 -0
- data/lib/action_view/helpers/tags/grouped_collection_select.rb +3 -1
- data/lib/action_view/helpers/tags/hidden_field.rb +2 -0
- data/lib/action_view/helpers/tags/label.rb +2 -4
- data/lib/action_view/helpers/tags/month_field.rb +2 -0
- data/lib/action_view/helpers/tags/number_field.rb +2 -0
- data/lib/action_view/helpers/tags/password_field.rb +2 -0
- data/lib/action_view/helpers/tags/placeholderable.rb +2 -0
- data/lib/action_view/helpers/tags/radio_button.rb +3 -1
- data/lib/action_view/helpers/tags/range_field.rb +2 -0
- data/lib/action_view/helpers/tags/search_field.rb +2 -0
- data/lib/action_view/helpers/tags/select.rb +4 -2
- data/lib/action_view/helpers/tags/tel_field.rb +2 -0
- data/lib/action_view/helpers/tags/text_area.rb +3 -1
- data/lib/action_view/helpers/tags/text_field.rb +3 -1
- data/lib/action_view/helpers/tags/time_field.rb +2 -0
- data/lib/action_view/helpers/tags/time_select.rb +2 -0
- data/lib/action_view/helpers/tags/time_zone_select.rb +3 -1
- data/lib/action_view/helpers/tags/translator.rb +2 -0
- data/lib/action_view/helpers/tags/url_field.rb +2 -0
- data/lib/action_view/helpers/tags/week_field.rb +2 -0
- data/lib/action_view/helpers/tags.rb +3 -1
- data/lib/action_view/helpers/text_helper.rb +9 -7
- data/lib/action_view/helpers/translation_helper.rb +17 -5
- data/lib/action_view/helpers/url_helper.rb +28 -4
- data/lib/action_view/helpers.rb +4 -0
- data/lib/action_view/layouts.rb +7 -5
- data/lib/action_view/log_subscriber.rb +5 -3
- data/lib/action_view/lookup_context.rb +4 -4
- data/lib/action_view/model_naming.rb +2 -0
- data/lib/action_view/path_set.rb +2 -0
- data/lib/action_view/railtie.rb +11 -2
- data/lib/action_view/record_identifier.rb +2 -0
- data/lib/action_view/renderer/abstract_renderer.rb +2 -0
- data/lib/action_view/renderer/partial_renderer/collection_caching.rb +4 -2
- data/lib/action_view/renderer/partial_renderer.rb +13 -11
- data/lib/action_view/renderer/renderer.rb +2 -0
- data/lib/action_view/renderer/streaming_template_renderer.rb +5 -1
- data/lib/action_view/renderer/template_renderer.rb +2 -0
- data/lib/action_view/rendering.rb +3 -5
- data/lib/action_view/routing_url_for.rb +2 -0
- data/lib/action_view/tasks/cache_digests.rake +2 -0
- data/lib/action_view/template/error.rb +2 -3
- data/lib/action_view/template/handlers/builder.rb +3 -4
- data/lib/action_view/template/handlers/erb/erubi.rb +2 -0
- data/lib/action_view/template/handlers/erb.rb +5 -9
- data/lib/action_view/template/handlers/html.rb +2 -0
- data/lib/action_view/template/handlers/raw.rb +2 -0
- data/lib/action_view/template/handlers.rb +3 -1
- data/lib/action_view/template/html.rb +3 -1
- data/lib/action_view/template/resolver.rb +7 -6
- data/lib/action_view/template/text.rb +3 -1
- data/lib/action_view/template/types.rb +3 -1
- data/lib/action_view/template.rb +6 -4
- data/lib/action_view/test_case.rb +21 -5
- data/lib/action_view/testing/resolvers.rb +3 -1
- data/lib/action_view/version.rb +2 -0
- data/lib/action_view/view_paths.rb +3 -3
- data/lib/action_view.rb +4 -3
- data/lib/assets/compiled/rails-ujs.js +52 -15
- metadata +15 -16
- data/lib/action_view/template/handlers/erb/deprecated_erubis.rb +0 -9
- data/lib/action_view/template/handlers/erb/erubis.rb +0 -81
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "action_view/helpers/tags/placeholderable"
|
2
4
|
|
3
5
|
module ActionView
|
@@ -14,7 +16,7 @@ module ActionView
|
|
14
16
|
options["cols"], options["rows"] = size.split("x") if size.respond_to?(:split)
|
15
17
|
end
|
16
18
|
|
17
|
-
content_tag("textarea", options.delete("value") { value_before_type_cast
|
19
|
+
content_tag("textarea", options.delete("value") { value_before_type_cast }, options)
|
18
20
|
end
|
19
21
|
end
|
20
22
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "action_view/helpers/tags/placeholderable"
|
2
4
|
|
3
5
|
module ActionView
|
@@ -10,7 +12,7 @@ module ActionView
|
|
10
12
|
options = @options.stringify_keys
|
11
13
|
options["size"] = options["maxlength"] unless options.key?("size")
|
12
14
|
options["type"] ||= field_type
|
13
|
-
options["value"] = options.fetch("value") { value_before_type_cast
|
15
|
+
options["value"] = options.fetch("value") { value_before_type_cast } unless field_type == "file"
|
14
16
|
add_default_name_and_id(options)
|
15
17
|
tag("input", options)
|
16
18
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActionView
|
2
4
|
module Helpers
|
3
5
|
module Tags # :nodoc:
|
@@ -11,7 +13,7 @@ module ActionView
|
|
11
13
|
|
12
14
|
def render
|
13
15
|
select_content_tag(
|
14
|
-
time_zone_options_for_select(value
|
16
|
+
time_zone_options_for_select(value || @options[:default], @priority_zones, @options[:model] || ActiveSupport::TimeZone), @options, @html_options
|
15
17
|
)
|
16
18
|
end
|
17
19
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "active_support/core_ext/string/filters"
|
2
4
|
require "active_support/core_ext/array/extract_options"
|
3
5
|
|
@@ -11,9 +13,9 @@ module ActionView
|
|
11
13
|
#
|
12
14
|
# ==== Sanitization
|
13
15
|
#
|
14
|
-
# Most text helpers
|
15
|
-
# This means HTML tags will appear in the page but all malicious
|
16
|
-
# Let's look at some examples using the +simple_format+ method:
|
16
|
+
# Most text helpers that generate HTML output sanitize the given input by default,
|
17
|
+
# but do not escape it. This means HTML tags will appear in the page but all malicious
|
18
|
+
# code will be removed. Let's look at some examples using the +simple_format+ method:
|
17
19
|
#
|
18
20
|
# simple_format('<a href="http://example.com/">Example</a>')
|
19
21
|
# # => "<p><a href=\"http://example.com/\">Example</a></p>"
|
@@ -126,7 +128,7 @@ module ActionView
|
|
126
128
|
# # => You searched for: <a href="search?q=rails">rails</a>
|
127
129
|
#
|
128
130
|
# highlight('<a href="javascript:alert(\'no!\')">ruby</a> on rails', 'rails', sanitize: false)
|
129
|
-
# # =>
|
131
|
+
# # => <a href="javascript:alert('no!')">ruby</a> on <mark>rails</mark>
|
130
132
|
def highlight(text, phrases, options = {})
|
131
133
|
text = sanitize(text) if options.fetch(:sanitize, true)
|
132
134
|
|
@@ -226,7 +228,7 @@ module ActionView
|
|
226
228
|
# pluralize(2, 'Person', locale: :de)
|
227
229
|
# # => 2 Personen
|
228
230
|
def pluralize(count, singular, plural_arg = nil, plural: plural_arg, locale: I18n.locale)
|
229
|
-
word = if (count == 1 || count =~ /^1(\.0+)?$/)
|
231
|
+
word = if (count == 1 || count.to_s =~ /^1(\.0+)?$/)
|
230
232
|
singular
|
231
233
|
else
|
232
234
|
plural || singular.pluralize(locale)
|
@@ -420,7 +422,7 @@ module ActionView
|
|
420
422
|
def to_s
|
421
423
|
value = @values[@index].to_s
|
422
424
|
@index = next_index
|
423
|
-
|
425
|
+
value
|
424
426
|
end
|
425
427
|
|
426
428
|
private
|
@@ -444,7 +446,7 @@ module ActionView
|
|
444
446
|
# uses an instance variable of ActionView::Base.
|
445
447
|
def get_cycle(name)
|
446
448
|
@_cycles = Hash.new unless defined?(@_cycles)
|
447
|
-
|
449
|
+
@_cycles[name]
|
448
450
|
end
|
449
451
|
|
450
452
|
def set_cycle(name, cycle_object)
|
@@ -1,18 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "action_view/helpers/tag_helper"
|
2
4
|
require "active_support/core_ext/string/access"
|
3
5
|
require "i18n/exceptions"
|
4
6
|
|
5
7
|
module ActionView
|
6
8
|
# = Action View Translation Helpers
|
7
|
-
module Helpers
|
9
|
+
module Helpers #:nodoc:
|
8
10
|
module TranslationHelper
|
9
11
|
extend ActiveSupport::Concern
|
10
12
|
|
11
13
|
include TagHelper
|
12
14
|
|
13
15
|
included do
|
14
|
-
mattr_accessor :debug_missing_translation
|
15
|
-
self.debug_missing_translation = true
|
16
|
+
mattr_accessor :debug_missing_translation, default: true
|
16
17
|
end
|
17
18
|
|
18
19
|
# Delegates to <tt>I18n#translate</tt> but also performs three additional
|
@@ -78,14 +79,22 @@ module ActionView
|
|
78
79
|
|
79
80
|
if html_safe_translation_key?(key)
|
80
81
|
html_safe_options = options.dup
|
82
|
+
|
81
83
|
options.except(*I18n::RESERVED_KEYS).each do |name, value|
|
82
84
|
unless name == :count && value.is_a?(Numeric)
|
83
85
|
html_safe_options[name] = ERB::Util.html_escape(value.to_s)
|
84
86
|
end
|
85
87
|
end
|
88
|
+
|
89
|
+
html_safe_options[:default] = MISSING_TRANSLATION unless html_safe_options[:default].blank?
|
90
|
+
|
86
91
|
translation = I18n.translate(scope_key_by_partial(key), html_safe_options.merge(raise: i18n_raise))
|
87
92
|
|
88
|
-
translation.
|
93
|
+
if translation.equal?(MISSING_TRANSLATION)
|
94
|
+
options[:default].first
|
95
|
+
else
|
96
|
+
translation.respond_to?(:html_safe) ? translation.html_safe : translation
|
97
|
+
end
|
89
98
|
else
|
90
99
|
I18n.translate(scope_key_by_partial(key), options.merge(raise: i18n_raise))
|
91
100
|
end
|
@@ -96,7 +105,7 @@ module ActionView
|
|
96
105
|
raise e if raise_error
|
97
106
|
|
98
107
|
keys = I18n.normalize_keys(e.locale, e.key, e.options[:scope])
|
99
|
-
title = "translation missing: #{keys.join('.')}"
|
108
|
+
title = "translation missing: #{keys.join('.')}".dup
|
100
109
|
|
101
110
|
interpolations = options.except(:default, :scope)
|
102
111
|
if interpolations.any?
|
@@ -120,6 +129,9 @@ module ActionView
|
|
120
129
|
alias :l :localize
|
121
130
|
|
122
131
|
private
|
132
|
+
MISSING_TRANSLATION = Object.new
|
133
|
+
private_constant :MISSING_TRANSLATION
|
134
|
+
|
123
135
|
def scope_key_by_partial(key)
|
124
136
|
if key.to_s.first == "."
|
125
137
|
if @virtual_path
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "action_view/helpers/javascript_helper"
|
2
4
|
require "active_support/core_ext/array/access"
|
3
5
|
require "active_support/core_ext/hash/keys"
|
@@ -137,6 +139,11 @@ module ActionView
|
|
137
139
|
# link_to "Profiles", controller: "profiles"
|
138
140
|
# # => <a href="/profiles">Profiles</a>
|
139
141
|
#
|
142
|
+
# When name is +nil+ the href is presented instead
|
143
|
+
#
|
144
|
+
# link_to nil, "http://example.com"
|
145
|
+
# # => <a href="http://www.example.com">http://www.example.com</a>
|
146
|
+
#
|
140
147
|
# You can use a block as well if your link target is hard to fit into the name parameter. ERB example:
|
141
148
|
#
|
142
149
|
# <%= link_to(@profile) do %>
|
@@ -246,7 +253,7 @@ module ActionView
|
|
246
253
|
# # <input value="New" type="submit" />
|
247
254
|
# # </form>"
|
248
255
|
#
|
249
|
-
# <%= button_to "New",
|
256
|
+
# <%= button_to "New", new_article_path %>
|
250
257
|
# # => "<form method="post" action="/articles/new" class="button_to">
|
251
258
|
# # <input value="New" type="submit" />
|
252
259
|
# # </form>"
|
@@ -587,10 +594,27 @@ module ActionView
|
|
587
594
|
end
|
588
595
|
|
589
596
|
def add_method_to_attributes!(html_options, method)
|
590
|
-
if method &&
|
591
|
-
|
597
|
+
if method_not_get_method?(method) && html_options["rel"] !~ /nofollow/
|
598
|
+
if html_options["rel"].blank?
|
599
|
+
html_options["rel"] = "nofollow"
|
600
|
+
else
|
601
|
+
html_options["rel"] = "#{html_options["rel"]} nofollow"
|
602
|
+
end
|
592
603
|
end
|
593
|
-
html_options["data-method"
|
604
|
+
html_options["data-method"] = method
|
605
|
+
end
|
606
|
+
|
607
|
+
STRINGIFIED_COMMON_METHODS = {
|
608
|
+
get: "get",
|
609
|
+
delete: "delete",
|
610
|
+
patch: "patch",
|
611
|
+
post: "post",
|
612
|
+
put: "put",
|
613
|
+
}.freeze
|
614
|
+
|
615
|
+
def method_not_get_method?(method)
|
616
|
+
return false unless method
|
617
|
+
(STRINGIFIED_COMMON_METHODS[method] || method.to_s.downcase) != "get"
|
594
618
|
end
|
595
619
|
|
596
620
|
def token_tag(token = nil, form_options: {})
|
data/lib/action_view/helpers.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "active_support/benchmarkable"
|
2
4
|
|
3
5
|
module ActionView #:nodoc:
|
@@ -11,6 +13,7 @@ module ActionView #:nodoc:
|
|
11
13
|
autoload :CacheHelper
|
12
14
|
autoload :CaptureHelper
|
13
15
|
autoload :ControllerHelper
|
16
|
+
autoload :CspHelper
|
14
17
|
autoload :CsrfHelper
|
15
18
|
autoload :DateHelper
|
16
19
|
autoload :DebugHelper
|
@@ -44,6 +47,7 @@ module ActionView #:nodoc:
|
|
44
47
|
include CacheHelper
|
45
48
|
include CaptureHelper
|
46
49
|
include ControllerHelper
|
50
|
+
include CspHelper
|
47
51
|
include CsrfHelper
|
48
52
|
include DateHelper
|
49
53
|
include DebugHelper
|
data/lib/action_view/layouts.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "action_view/rendering"
|
2
|
-
require "active_support/core_ext/module/
|
4
|
+
require "active_support/core_ext/module/redefine_method"
|
3
5
|
|
4
6
|
module ActionView
|
5
7
|
# Layouts reverse the common pattern of including shared headers and footers in many templates to isolate changes in
|
@@ -204,9 +206,9 @@ module ActionView
|
|
204
206
|
include ActionView::Rendering
|
205
207
|
|
206
208
|
included do
|
207
|
-
class_attribute :_layout,
|
208
|
-
|
209
|
-
|
209
|
+
class_attribute :_layout, instance_accessor: false
|
210
|
+
class_attribute :_layout_conditions, instance_accessor: false, default: {}
|
211
|
+
|
210
212
|
_write_layout_method
|
211
213
|
end
|
212
214
|
|
@@ -277,7 +279,7 @@ module ActionView
|
|
277
279
|
# If a layout is not explicitly mentioned then look for a layout with the controller's name.
|
278
280
|
# if nothing is found then try same procedure to find super class's layout.
|
279
281
|
def _write_layout_method # :nodoc:
|
280
|
-
|
282
|
+
silence_redefinition_of_method(:_layout)
|
281
283
|
|
282
284
|
prefixes = /\blayouts/.match?(_implied_layout_name) ? [] : ["layouts"]
|
283
285
|
default_behavior = "lookup_context.find_all('#{_implied_layout_name}', #{prefixes.inspect}, false, [], { formats: formats }).first || super"
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "active_support/log_subscriber"
|
2
4
|
|
3
5
|
module ActionView
|
@@ -14,7 +16,7 @@ module ActionView
|
|
14
16
|
|
15
17
|
def render_template(event)
|
16
18
|
info do
|
17
|
-
message = " Rendered #{from_rails_root(event.payload[:identifier])}"
|
19
|
+
message = " Rendered #{from_rails_root(event.payload[:identifier])}".dup
|
18
20
|
message << " within #{from_rails_root(event.payload[:layout])}" if event.payload[:layout]
|
19
21
|
message << " (#{event.duration.round(1)}ms)"
|
20
22
|
end
|
@@ -22,7 +24,7 @@ module ActionView
|
|
22
24
|
|
23
25
|
def render_partial(event)
|
24
26
|
info do
|
25
|
-
message = " Rendered #{from_rails_root(event.payload[:identifier])}"
|
27
|
+
message = " Rendered #{from_rails_root(event.payload[:identifier])}".dup
|
26
28
|
message << " within #{from_rails_root(event.payload[:layout])}" if event.payload[:layout]
|
27
29
|
message << " (#{event.duration.round(1)}ms)"
|
28
30
|
message << " #{cache_message(event.payload)}" unless event.payload[:cache_hit].nil?
|
@@ -83,7 +85,7 @@ module ActionView
|
|
83
85
|
|
84
86
|
def log_rendering_start(payload)
|
85
87
|
info do
|
86
|
-
message = " Rendering #{from_rails_root(payload[:identifier])}"
|
88
|
+
message = " Rendering #{from_rails_root(payload[:identifier])}".dup
|
87
89
|
message << " within #{from_rails_root(payload[:layout])}" if payload[:layout]
|
88
90
|
message
|
89
91
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "concurrent/map"
|
2
4
|
require "active_support/core_ext/module/remove_method"
|
3
5
|
require "active_support/core_ext/module/attribute_accessors"
|
@@ -14,11 +16,9 @@ module ActionView
|
|
14
16
|
class LookupContext #:nodoc:
|
15
17
|
attr_accessor :prefixes, :rendered_format
|
16
18
|
|
17
|
-
mattr_accessor :fallbacks
|
18
|
-
@@fallbacks = FallbackFileSystemResolver.instances
|
19
|
+
mattr_accessor :fallbacks, default: FallbackFileSystemResolver.instances
|
19
20
|
|
20
|
-
mattr_accessor :registered_details
|
21
|
-
self.registered_details = []
|
21
|
+
mattr_accessor :registered_details, default: []
|
22
22
|
|
23
23
|
def self.register_detail(name, &block)
|
24
24
|
registered_details << name
|
data/lib/action_view/path_set.rb
CHANGED
data/lib/action_view/railtie.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "action_view"
|
2
4
|
require "rails"
|
3
5
|
|
@@ -20,8 +22,15 @@ module ActionView
|
|
20
22
|
initializer "action_view.form_with_generates_remote_forms" do |app|
|
21
23
|
ActiveSupport.on_load(:action_view) do
|
22
24
|
form_with_generates_remote_forms = app.config.action_view.delete(:form_with_generates_remote_forms)
|
23
|
-
|
24
|
-
|
25
|
+
ActionView::Helpers::FormHelper.form_with_generates_remote_forms = form_with_generates_remote_forms
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
initializer "action_view.form_with_generates_ids" do |app|
|
30
|
+
ActiveSupport.on_load(:action_view) do
|
31
|
+
form_with_generates_ids = app.config.action_view.delete(:form_with_generates_ids)
|
32
|
+
unless form_with_generates_ids.nil?
|
33
|
+
ActionView::Helpers::FormHelper.form_with_generates_ids = form_with_generates_ids
|
25
34
|
end
|
26
35
|
end
|
27
36
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActionView
|
2
4
|
module CollectionCaching # :nodoc:
|
3
5
|
extend ActiveSupport::Concern
|
@@ -5,7 +7,7 @@ module ActionView
|
|
5
7
|
included do
|
6
8
|
# Fallback cache store if Action View is used without Rails.
|
7
9
|
# Otherwise overridden in Railtie to use Rails.cache.
|
8
|
-
mattr_accessor
|
10
|
+
mattr_accessor :collection_cache, default: ActiveSupport::Cache::MemoryStore.new
|
9
11
|
end
|
10
12
|
|
11
13
|
private
|
@@ -38,7 +40,7 @@ module ActionView
|
|
38
40
|
end
|
39
41
|
|
40
42
|
def expanded_cache_key(key)
|
41
|
-
key = @view.
|
43
|
+
key = @view.combined_fragment_cache_key(@view.cache_fragment_name(key, virtual_path: @template.virtual_path))
|
42
44
|
key.frozen? ? key.dup : key # #read_multi & #write may require mutability, Dalli 2.6.0.
|
43
45
|
end
|
44
46
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "concurrent/map"
|
2
4
|
require "action_view/renderer/partial_renderer/collection_caching"
|
3
5
|
|
@@ -50,12 +52,12 @@ module ActionView
|
|
50
52
|
# <%= render partial: "ad", locals: { ad: ad } %>
|
51
53
|
# <% end %>
|
52
54
|
#
|
53
|
-
# This would first render
|
54
|
-
# render
|
55
|
+
# This would first render <tt>advertiser/_account.html.erb</tt> with <tt>@buyer</tt> passed in as the local variable +account+, then
|
56
|
+
# render <tt>advertiser/_ad.html.erb</tt> and pass the local variable +ad+ to the template for display.
|
55
57
|
#
|
56
58
|
# == The :as and :object options
|
57
59
|
#
|
58
|
-
# By default
|
60
|
+
# By default ActionView::PartialRenderer doesn't have any local variables.
|
59
61
|
# The <tt>:object</tt> option can be used to pass an object to the partial. For instance:
|
60
62
|
#
|
61
63
|
# <%= render partial: "account", object: @buyer %>
|
@@ -83,7 +85,7 @@ module ActionView
|
|
83
85
|
#
|
84
86
|
# <%= render partial: "ad", collection: @advertisements %>
|
85
87
|
#
|
86
|
-
# This will render
|
88
|
+
# This will render <tt>advertiser/_ad.html.erb</tt> and pass the local variable +ad+ to the template for display. An
|
87
89
|
# iteration object will automatically be made available to the template with a name of the form
|
88
90
|
# +partial_name_iteration+. The iteration object has knowledge about which index the current object has in
|
89
91
|
# the collection and the total size of the collection. The iteration object also has two convenience methods,
|
@@ -98,7 +100,7 @@ module ActionView
|
|
98
100
|
#
|
99
101
|
# <%= render partial: "ad", collection: @advertisements, spacer_template: "ad_divider" %>
|
100
102
|
#
|
101
|
-
# If the given <tt>:collection</tt> is +nil+ or empty, <tt>render</tt> will return nil
|
103
|
+
# If the given <tt>:collection</tt> is +nil+ or empty, <tt>render</tt> will return +nil+. This will allow you
|
102
104
|
# to specify a text which will be displayed instead by using this form:
|
103
105
|
#
|
104
106
|
# <%= render(partial: "ad", collection: @advertisements) || "There's no ad to be displayed" %>
|
@@ -112,18 +114,18 @@ module ActionView
|
|
112
114
|
#
|
113
115
|
# <%= render partial: "advertisement/ad", locals: { ad: @advertisement } %>
|
114
116
|
#
|
115
|
-
# This will render the partial
|
117
|
+
# This will render the partial <tt>advertisement/_ad.html.erb</tt> regardless of which controller this is being called from.
|
116
118
|
#
|
117
|
-
# == \Rendering objects that respond to
|
119
|
+
# == \Rendering objects that respond to +to_partial_path+
|
118
120
|
#
|
119
121
|
# Instead of explicitly naming the location of a partial, you can also let PartialRenderer do the work
|
120
|
-
# and pick the proper path by checking
|
122
|
+
# and pick the proper path by checking +to_partial_path+ method.
|
121
123
|
#
|
122
124
|
# # @account.to_partial_path returns 'accounts/account', so it can be used to replace:
|
123
125
|
# # <%= render partial: "accounts/account", locals: { account: @account} %>
|
124
126
|
# <%= render partial: @account %>
|
125
127
|
#
|
126
|
-
# # @posts is an array of Post instances, so every post record returns 'posts/post' on
|
128
|
+
# # @posts is an array of Post instances, so every post record returns 'posts/post' on +to_partial_path+,
|
127
129
|
# # that's why we can replace:
|
128
130
|
# # <%= render partial: "posts/post", collection: @posts %>
|
129
131
|
# <%= render partial: @posts %>
|
@@ -143,7 +145,7 @@ module ActionView
|
|
143
145
|
# # <%= render partial: "accounts/account", locals: { account: @account} %>
|
144
146
|
# <%= render @account %>
|
145
147
|
#
|
146
|
-
# # @posts is an array of Post instances, so every post record returns 'posts/post' on
|
148
|
+
# # @posts is an array of Post instances, so every post record returns 'posts/post' on +to_partial_path+,
|
147
149
|
# # that's why we can replace:
|
148
150
|
# # <%= render partial: "posts/post", collection: @posts %>
|
149
151
|
# <%= render @posts %>
|
@@ -353,7 +355,7 @@ module ActionView
|
|
353
355
|
# finds the options and details and extracts them. The method also contains
|
354
356
|
# logic that handles the type of object passed in as the partial.
|
355
357
|
#
|
356
|
-
# If +options[:partial]+ is a string, then the
|
358
|
+
# If +options[:partial]+ is a string, then the <tt>@path</tt> instance variable is
|
357
359
|
# set to that string. Otherwise, the +options[:partial]+ object must
|
358
360
|
# respond to +to_partial_path+ in order to setup the path.
|
359
361
|
def setup(context, options, block)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "fiber"
|
2
4
|
|
3
5
|
module ActionView
|
@@ -31,7 +33,7 @@ module ActionView
|
|
31
33
|
logger = ActionView::Base.logger
|
32
34
|
return unless logger
|
33
35
|
|
34
|
-
message = "\n#{exception.class} (#{exception.message}):\n"
|
36
|
+
message = "\n#{exception.class} (#{exception.message}):\n".dup
|
35
37
|
message << exception.annoted_source_code.to_s if exception.respond_to?(:annoted_source_code)
|
36
38
|
message << " " << exception.backtrace.join("\n ")
|
37
39
|
logger.fatal("#{message}\n\n")
|
@@ -63,7 +65,9 @@ module ActionView
|
|
63
65
|
yielder = lambda { |*name| view._layout_for(*name) }
|
64
66
|
|
65
67
|
instrument(:template, identifier: template.identifier, layout: layout.try(:virtual_path)) do
|
68
|
+
outer_config = I18n.config
|
66
69
|
fiber = Fiber.new do
|
70
|
+
I18n.config = outer_config
|
67
71
|
if layout
|
68
72
|
layout.render(view, locals, output, &yielder)
|
69
73
|
else
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "action_view/view_paths"
|
2
4
|
|
3
5
|
module ActionView
|
@@ -73,8 +75,7 @@ module ActionView
|
|
73
75
|
end
|
74
76
|
|
75
77
|
# Returns an object that is able to render templates.
|
76
|
-
# :
|
77
|
-
def view_renderer
|
78
|
+
def view_renderer # :nodoc:
|
78
79
|
@_view_renderer ||= ActionView::Renderer.new(lookup_context)
|
79
80
|
end
|
80
81
|
|
@@ -90,7 +91,6 @@ module ActionView
|
|
90
91
|
private
|
91
92
|
|
92
93
|
# Find and render a template based on the options given.
|
93
|
-
# :api: private
|
94
94
|
def _render_template(options)
|
95
95
|
variant = options.delete(:variant)
|
96
96
|
assigns = options.delete(:assigns)
|
@@ -112,7 +112,6 @@ module ActionView
|
|
112
112
|
|
113
113
|
# Normalize args by converting render "foo" to render :action => "foo" and
|
114
114
|
# render "foo/bar" to render :template => "foo/bar".
|
115
|
-
# :api: private
|
116
115
|
def _normalize_args(action = nil, options = {})
|
117
116
|
options = super(action, options)
|
118
117
|
case action
|
@@ -135,7 +134,6 @@ module ActionView
|
|
135
134
|
end
|
136
135
|
|
137
136
|
# Normalize options.
|
138
|
-
# :api: private
|
139
137
|
def _normalize_options(options)
|
140
138
|
options = super(options)
|
141
139
|
if options[:partial] == true
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "active_support/core_ext/enumerable"
|
2
4
|
|
3
5
|
module ActionView
|
@@ -8,9 +10,6 @@ module ActionView
|
|
8
10
|
class EncodingError < StandardError #:nodoc:
|
9
11
|
end
|
10
12
|
|
11
|
-
class MissingRequestError < StandardError #:nodoc:
|
12
|
-
end
|
13
|
-
|
14
13
|
class WrongEncodingError < EncodingError #:nodoc:
|
15
14
|
def initialize(string, encoding)
|
16
15
|
@string, @encoding = string, encoding
|