actionview 4.2.11.1 → 6.0.4
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 +201 -192
- data/MIT-LICENSE +1 -1
- data/README.rdoc +9 -8
- data/lib/action_view/base.rb +144 -37
- data/lib/action_view/buffers.rb +18 -1
- data/lib/action_view/cache_expiry.rb +53 -0
- data/lib/action_view/context.rb +8 -12
- data/lib/action_view/dependency_tracker.rb +54 -20
- data/lib/action_view/digestor.rb +88 -85
- data/lib/action_view/flows.rb +11 -12
- data/lib/action_view/gem_version.rb +6 -4
- data/lib/action_view/helpers/active_model_helper.rb +16 -11
- data/lib/action_view/helpers/asset_tag_helper.rb +241 -82
- data/lib/action_view/helpers/asset_url_helper.rb +171 -67
- data/lib/action_view/helpers/atom_feed_helper.rb +19 -17
- data/lib/action_view/helpers/cache_helper.rb +112 -42
- data/lib/action_view/helpers/capture_helper.rb +20 -13
- data/lib/action_view/helpers/controller_helper.rb +15 -4
- data/lib/action_view/helpers/csp_helper.rb +26 -0
- data/lib/action_view/helpers/csrf_helper.rb +8 -6
- data/lib/action_view/helpers/date_helper.rb +230 -129
- data/lib/action_view/helpers/debug_helper.rb +7 -6
- data/lib/action_view/helpers/form_helper.rb +755 -129
- data/lib/action_view/helpers/form_options_helper.rb +130 -75
- data/lib/action_view/helpers/form_tag_helper.rb +116 -71
- data/lib/action_view/helpers/javascript_helper.rb +30 -14
- data/lib/action_view/helpers/number_helper.rb +84 -59
- data/lib/action_view/helpers/output_safety_helper.rb +36 -4
- data/lib/action_view/helpers/rendering_helper.rb +11 -8
- data/lib/action_view/helpers/sanitize_helper.rb +30 -31
- data/lib/action_view/helpers/tag_helper.rb +201 -75
- data/lib/action_view/helpers/tags/base.rb +138 -98
- data/lib/action_view/helpers/tags/check_box.rb +20 -19
- data/lib/action_view/helpers/tags/checkable.rb +4 -2
- data/lib/action_view/helpers/tags/collection_check_boxes.rb +12 -34
- data/lib/action_view/helpers/tags/collection_helpers.rb +69 -36
- data/lib/action_view/helpers/tags/collection_radio_buttons.rb +6 -12
- data/lib/action_view/helpers/tags/collection_select.rb +4 -2
- data/lib/action_view/helpers/tags/color_field.rb +4 -3
- data/lib/action_view/helpers/tags/date_field.rb +2 -1
- data/lib/action_view/helpers/tags/date_select.rb +37 -36
- data/lib/action_view/helpers/tags/datetime_field.rb +4 -3
- data/lib/action_view/helpers/tags/datetime_local_field.rb +2 -1
- 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 +4 -2
- data/lib/action_view/helpers/tags/hidden_field.rb +2 -0
- data/lib/action_view/helpers/tags/label.rb +3 -2
- data/lib/action_view/helpers/tags/month_field.rb +2 -1
- data/lib/action_view/helpers/tags/number_field.rb +2 -0
- data/lib/action_view/helpers/tags/password_field.rb +3 -1
- data/lib/action_view/helpers/tags/placeholderable.rb +3 -1
- data/lib/action_view/helpers/tags/radio_button.rb +7 -6
- data/lib/action_view/helpers/tags/range_field.rb +2 -0
- data/lib/action_view/helpers/tags/search_field.rb +14 -9
- data/lib/action_view/helpers/tags/select.rb +11 -10
- data/lib/action_view/helpers/tags/tel_field.rb +2 -0
- data/lib/action_view/helpers/tags/text_area.rb +4 -2
- data/lib/action_view/helpers/tags/text_field.rb +8 -8
- data/lib/action_view/helpers/tags/time_field.rb +2 -1
- 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 +15 -16
- data/lib/action_view/helpers/tags/url_field.rb +2 -0
- data/lib/action_view/helpers/tags/week_field.rb +2 -1
- data/lib/action_view/helpers/tags.rb +3 -1
- data/lib/action_view/helpers/text_helper.rb +56 -38
- data/lib/action_view/helpers/translation_helper.rb +91 -47
- data/lib/action_view/helpers/url_helper.rb +160 -105
- data/lib/action_view/helpers.rb +5 -3
- data/lib/action_view/layouts.rb +65 -61
- data/lib/action_view/log_subscriber.rb +61 -10
- data/lib/action_view/lookup_context.rb +147 -89
- data/lib/action_view/model_naming.rb +3 -1
- data/lib/action_view/path_set.rb +28 -23
- data/lib/action_view/railtie.rb +62 -6
- data/lib/action_view/record_identifier.rb +53 -26
- data/lib/action_view/renderer/abstract_renderer.rb +71 -13
- data/lib/action_view/renderer/partial_renderer/collection_caching.rb +103 -0
- data/lib/action_view/renderer/partial_renderer.rb +239 -225
- data/lib/action_view/renderer/renderer.rb +22 -8
- data/lib/action_view/renderer/streaming_template_renderer.rb +54 -54
- data/lib/action_view/renderer/template_renderer.rb +79 -73
- data/lib/action_view/rendering.rb +68 -44
- data/lib/action_view/routing_url_for.rb +33 -22
- data/lib/action_view/tasks/cache_digests.rake +25 -0
- data/lib/action_view/template/error.rb +44 -29
- data/lib/action_view/template/handlers/builder.rb +12 -13
- data/lib/action_view/template/handlers/erb/erubi.rb +87 -0
- data/lib/action_view/template/handlers/erb.rb +24 -86
- data/lib/action_view/template/handlers/html.rb +11 -0
- data/lib/action_view/template/handlers/raw.rb +4 -4
- data/lib/action_view/template/handlers.rb +38 -8
- data/lib/action_view/template/html.rb +19 -10
- data/lib/action_view/template/inline.rb +22 -0
- data/lib/action_view/template/raw_file.rb +28 -0
- data/lib/action_view/template/resolver.rb +217 -193
- data/lib/action_view/template/sources/file.rb +17 -0
- data/lib/action_view/template/sources.rb +13 -0
- data/lib/action_view/template/text.rb +11 -10
- data/lib/action_view/template/types.rb +18 -18
- data/lib/action_view/template.rb +146 -90
- data/lib/action_view/test_case.rb +52 -32
- data/lib/action_view/testing/resolvers.rb +46 -34
- data/lib/action_view/unbound_template.rb +31 -0
- data/lib/action_view/version.rb +3 -1
- data/lib/action_view/view_paths.rb +48 -31
- data/lib/action_view.rb +11 -8
- data/lib/assets/compiled/rails-ujs.js +746 -0
- metadata +38 -29
- data/lib/action_view/helpers/record_tag_helper.rb +0 -108
- data/lib/action_view/tasks/dependencies.rake +0 -23
@@ -1,54 +1,66 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "action_view/template/resolver"
|
2
4
|
|
3
5
|
module ActionView #:nodoc:
|
4
6
|
# Use FixtureResolver in your tests to simulate the presence of files on the
|
5
7
|
# file system. This is used internally by Rails' own test suite, and is
|
6
8
|
# useful for testing extensions that have no way of knowing what the file
|
7
9
|
# system will look like at runtime.
|
8
|
-
class FixtureResolver <
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
class FixtureResolver < OptimizedFileSystemResolver
|
11
|
+
def initialize(hash = {}, pattern = nil)
|
12
|
+
super("")
|
13
|
+
if pattern
|
14
|
+
ActiveSupport::Deprecation.warn "Specifying a custom path for #{self.class} is deprecated. Implement a custom Resolver subclass instead."
|
15
|
+
@pattern = pattern
|
16
|
+
end
|
13
17
|
@hash = hash
|
18
|
+
@path = ""
|
19
|
+
end
|
20
|
+
|
21
|
+
def data
|
22
|
+
@hash
|
14
23
|
end
|
15
24
|
|
16
25
|
def to_s
|
17
|
-
@hash.keys.join(
|
26
|
+
@hash.keys.join(", ")
|
18
27
|
end
|
19
28
|
|
20
|
-
|
29
|
+
private
|
30
|
+
def query(path, exts, _, locals, cache:)
|
31
|
+
regex = build_regex(path, exts)
|
21
32
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
end
|
27
|
-
query = /^(#{Regexp.escape(path)})#{query}$/
|
28
|
-
|
29
|
-
templates = []
|
30
|
-
@hash.each do |_path, array|
|
31
|
-
source, updated_at = array
|
32
|
-
next unless _path =~ query
|
33
|
-
handler, format, variant = extract_handler_and_format_and_variant(_path, formats)
|
34
|
-
templates << Template.new(source, _path, handler,
|
35
|
-
:virtual_path => path.virtual,
|
36
|
-
:format => format,
|
37
|
-
:variant => variant,
|
38
|
-
:updated_at => updated_at
|
39
|
-
)
|
40
|
-
end
|
33
|
+
@hash.select do |_path, _|
|
34
|
+
("/" + _path).match?(regex)
|
35
|
+
end.map do |_path, source|
|
36
|
+
handler, format, variant = extract_handler_and_format_and_variant(_path)
|
41
37
|
|
42
|
-
|
43
|
-
|
38
|
+
Template.new(source, _path, handler,
|
39
|
+
virtual_path: path.virtual,
|
40
|
+
format: format,
|
41
|
+
variant: variant,
|
42
|
+
locals: locals
|
43
|
+
)
|
44
|
+
end.sort_by do |t|
|
45
|
+
match = ("/" + t.identifier).match(regex)
|
46
|
+
EXTENSIONS.keys.reverse.map do |ext|
|
47
|
+
if ext == :variants && exts[ext] == :any
|
48
|
+
match[ext].nil? ? 0 : 1
|
49
|
+
elsif match[ext].nil?
|
50
|
+
exts[ext].length
|
51
|
+
else
|
52
|
+
found = match[ext].to_sym
|
53
|
+
exts[ext].index(found)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
44
58
|
end
|
45
59
|
|
46
60
|
class NullResolver < PathResolver
|
47
|
-
def query(path, exts,
|
48
|
-
handler, format, variant = extract_handler_and_format_and_variant(path
|
49
|
-
[ActionView::Template.new("Template generated by Null Resolver", path, handler, :
|
61
|
+
def query(path, exts, _, locals, cache:)
|
62
|
+
handler, format, variant = extract_handler_and_format_and_variant(path)
|
63
|
+
[ActionView::Template.new("Template generated by Null Resolver", path.virtual, handler, virtual_path: path.virtual, format: format, variant: variant, locals: locals)]
|
50
64
|
end
|
51
65
|
end
|
52
|
-
|
53
66
|
end
|
54
|
-
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "concurrent/map"
|
4
|
+
|
5
|
+
module ActionView
|
6
|
+
class UnboundTemplate
|
7
|
+
def initialize(source, identifer, handler, options)
|
8
|
+
@source = source
|
9
|
+
@identifer = identifer
|
10
|
+
@handler = handler
|
11
|
+
@options = options
|
12
|
+
|
13
|
+
@templates = Concurrent::Map.new(initial_capacity: 2)
|
14
|
+
end
|
15
|
+
|
16
|
+
def bind_locals(locals)
|
17
|
+
@templates[locals] ||= build_template(locals)
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
def build_template(locals)
|
22
|
+
options = @options.merge(locals: locals)
|
23
|
+
Template.new(
|
24
|
+
@source,
|
25
|
+
@identifer,
|
26
|
+
@handler,
|
27
|
+
**options
|
28
|
+
)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/action_view/version.rb
CHANGED
@@ -1,73 +1,90 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module ActionView
|
4
4
|
module ViewPaths
|
5
5
|
extend ActiveSupport::Concern
|
6
6
|
|
7
7
|
included do
|
8
|
-
|
9
|
-
self._view_paths = ActionView::PathSet.new
|
10
|
-
self._view_paths.freeze
|
8
|
+
ViewPaths.set_view_paths(self, ActionView::PathSet.new.freeze)
|
11
9
|
end
|
12
10
|
|
13
|
-
delegate :template_exists?, :view_paths, :formats, :formats=,
|
14
|
-
:locale, :locale=, :
|
11
|
+
delegate :template_exists?, :any_templates?, :view_paths, :formats, :formats=,
|
12
|
+
:locale, :locale=, to: :lookup_context
|
15
13
|
|
16
14
|
module ClassMethods
|
15
|
+
def _view_paths
|
16
|
+
ViewPaths.get_view_paths(self)
|
17
|
+
end
|
18
|
+
|
19
|
+
def _view_paths=(paths)
|
20
|
+
ViewPaths.set_view_paths(self, paths)
|
21
|
+
end
|
22
|
+
|
17
23
|
def _prefixes # :nodoc:
|
18
24
|
@_prefixes ||= begin
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
else
|
23
|
-
return local_prefixes if superclass.abstract?
|
24
|
-
|
25
|
-
local_prefixes + superclass._prefixes
|
26
|
-
end
|
25
|
+
return local_prefixes if superclass.abstract?
|
26
|
+
|
27
|
+
local_prefixes + superclass._prefixes
|
27
28
|
end
|
28
29
|
end
|
29
30
|
|
30
31
|
private
|
32
|
+
# Override this method in your controller if you want to change paths prefixes for finding views.
|
33
|
+
# Prefixes defined here will still be added to parents' <tt>._prefixes</tt>.
|
34
|
+
def local_prefixes
|
35
|
+
[controller_path]
|
36
|
+
end
|
37
|
+
end
|
31
38
|
|
32
|
-
|
33
|
-
|
34
|
-
def local_prefixes
|
35
|
-
[controller_path]
|
36
|
-
end
|
39
|
+
# :stopdoc:
|
40
|
+
@all_view_paths = {}
|
37
41
|
|
38
|
-
|
39
|
-
|
42
|
+
def self.get_view_paths(klass)
|
43
|
+
@all_view_paths[klass] || get_view_paths(klass.superclass)
|
44
|
+
end
|
40
45
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
MSG
|
46
|
+
def self.set_view_paths(klass, paths)
|
47
|
+
@all_view_paths[klass] = paths
|
48
|
+
end
|
45
49
|
|
46
|
-
|
47
|
-
|
50
|
+
def self.all_view_paths
|
51
|
+
@all_view_paths.values.uniq
|
48
52
|
end
|
53
|
+
# :startdoc:
|
49
54
|
|
50
55
|
# The prefixes used in render "foo" shortcuts.
|
51
56
|
def _prefixes # :nodoc:
|
52
57
|
self.class._prefixes
|
53
58
|
end
|
54
59
|
|
55
|
-
# LookupContext is the object responsible
|
56
|
-
# templates, i.e. view paths and
|
57
|
-
# information.
|
60
|
+
# <tt>LookupContext</tt> is the object responsible for holding all
|
61
|
+
# information required for looking up templates, i.e. view paths and
|
62
|
+
# details. Check <tt>ActionView::LookupContext</tt> for more information.
|
58
63
|
def lookup_context
|
59
64
|
@_lookup_context ||=
|
60
65
|
ActionView::LookupContext.new(self.class._view_paths, details_for_lookup, _prefixes)
|
61
66
|
end
|
62
67
|
|
63
68
|
def details_for_lookup
|
64
|
-
{
|
69
|
+
{}
|
65
70
|
end
|
66
71
|
|
72
|
+
# Append a path to the list of view paths for the current <tt>LookupContext</tt>.
|
73
|
+
#
|
74
|
+
# ==== Parameters
|
75
|
+
# * <tt>path</tt> - If a String is provided, it gets converted into
|
76
|
+
# the default view path. You may also provide a custom view path
|
77
|
+
# (see ActionView::PathSet for more information)
|
67
78
|
def append_view_path(path)
|
68
79
|
lookup_context.view_paths.push(*path)
|
69
80
|
end
|
70
81
|
|
82
|
+
# Prepend a path to the list of view paths for the current <tt>LookupContext</tt>.
|
83
|
+
#
|
84
|
+
# ==== Parameters
|
85
|
+
# * <tt>path</tt> - If a String is provided, it gets converted into
|
86
|
+
# the default view path. You may also provide a custom view path
|
87
|
+
# (see ActionView::PathSet for more information)
|
71
88
|
def prepend_view_path(path)
|
72
89
|
lookup_context.view_paths.unshift(*path)
|
73
90
|
end
|
data/lib/action_view.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
#--
|
2
|
-
# Copyright (c) 2004-
|
4
|
+
# Copyright (c) 2004-2019 David Heinemeier Hansson
|
3
5
|
#
|
4
6
|
# Permission is hereby granted, free of charge, to any person obtaining
|
5
7
|
# a copy of this software and associated documentation files (the
|
@@ -21,9 +23,9 @@
|
|
21
23
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
24
|
#++
|
23
25
|
|
24
|
-
require
|
25
|
-
require
|
26
|
-
require
|
26
|
+
require "active_support"
|
27
|
+
require "active_support/rails"
|
28
|
+
require "action_view/version"
|
27
29
|
|
28
30
|
module ActionView
|
29
31
|
extend ActiveSupport::Autoload
|
@@ -33,7 +35,6 @@ module ActionView
|
|
33
35
|
eager_autoload do
|
34
36
|
autoload :Base
|
35
37
|
autoload :Context
|
36
|
-
autoload :CompiledTemplates, "action_view/context"
|
37
38
|
autoload :Digestor
|
38
39
|
autoload :Helpers
|
39
40
|
autoload :LookupContext
|
@@ -43,6 +44,7 @@ module ActionView
|
|
43
44
|
autoload :Rendering
|
44
45
|
autoload :RoutingUrlFor
|
45
46
|
autoload :Template
|
47
|
+
autoload :UnboundTemplate
|
46
48
|
autoload :ViewPaths
|
47
49
|
|
48
50
|
autoload_under "renderer" do
|
@@ -74,12 +76,13 @@ module ActionView
|
|
74
76
|
autoload :MissingTemplate
|
75
77
|
autoload :ActionViewError
|
76
78
|
autoload :EncodingError
|
77
|
-
autoload :MissingRequestError
|
78
79
|
autoload :TemplateError
|
80
|
+
autoload :SyntaxErrorInTemplate
|
79
81
|
autoload :WrongEncodingError
|
80
82
|
end
|
81
83
|
end
|
82
84
|
|
85
|
+
autoload :CacheExpiry
|
83
86
|
autoload :TestCase
|
84
87
|
|
85
88
|
def self.eager_load!
|
@@ -89,8 +92,8 @@ module ActionView
|
|
89
92
|
end
|
90
93
|
end
|
91
94
|
|
92
|
-
require
|
95
|
+
require "active_support/core_ext/string/output_safety"
|
93
96
|
|
94
97
|
ActiveSupport.on_load(:i18n) do
|
95
|
-
I18n.load_path <<
|
98
|
+
I18n.load_path << File.expand_path("action_view/locale/en.yml", __dir__)
|
96
99
|
end
|