actionview 7.0.8 → 7.2.0
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 +54 -439
- data/MIT-LICENSE +1 -1
- data/README.rdoc +1 -1
- 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 +52 -14
- data/lib/action_view/buffers.rb +106 -8
- data/lib/action_view/cache_expiry.rb +44 -41
- data/lib/action_view/context.rb +1 -1
- data/lib/action_view/dependency_tracker/{ripper_tracker.rb → ruby_tracker.rb} +4 -3
- data/lib/action_view/dependency_tracker.rb +1 -1
- data/lib/action_view/deprecator.rb +7 -0
- data/lib/action_view/digestor.rb +1 -1
- data/lib/action_view/gem_version.rb +3 -3
- data/lib/action_view/helpers/active_model_helper.rb +1 -1
- data/lib/action_view/helpers/asset_tag_helper.rb +151 -55
- data/lib/action_view/helpers/asset_url_helper.rb +6 -5
- data/lib/action_view/helpers/atom_feed_helper.rb +5 -5
- data/lib/action_view/helpers/cache_helper.rb +7 -13
- data/lib/action_view/helpers/capture_helper.rb +30 -10
- data/lib/action_view/helpers/content_exfiltration_prevention_helper.rb +70 -0
- data/lib/action_view/helpers/controller_helper.rb +6 -0
- data/lib/action_view/helpers/csp_helper.rb +2 -2
- data/lib/action_view/helpers/csrf_helper.rb +3 -3
- data/lib/action_view/helpers/date_helper.rb +17 -19
- data/lib/action_view/helpers/debug_helper.rb +3 -3
- data/lib/action_view/helpers/form_helper.rb +248 -214
- data/lib/action_view/helpers/form_options_helper.rb +2 -1
- data/lib/action_view/helpers/form_tag_helper.rb +121 -54
- data/lib/action_view/helpers/javascript_helper.rb +1 -0
- data/lib/action_view/helpers/number_helper.rb +37 -330
- data/lib/action_view/helpers/output_safety_helper.rb +6 -6
- data/lib/action_view/helpers/rendering_helper.rb +1 -1
- data/lib/action_view/helpers/sanitize_helper.rb +51 -21
- data/lib/action_view/helpers/tag_helper.rb +210 -42
- data/lib/action_view/helpers/tags/base.rb +11 -52
- 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 +3 -0
- 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/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 +3 -0
- data/lib/action_view/helpers/tags/select_renderer.rb +56 -0
- data/lib/action_view/helpers/tags/time_field.rb +1 -1
- 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 +3 -0
- data/lib/action_view/helpers/tags.rb +2 -0
- data/lib/action_view/helpers/text_helper.rb +156 -84
- data/lib/action_view/helpers/translation_helper.rb +3 -3
- data/lib/action_view/helpers/url_helper.rb +31 -78
- data/lib/action_view/helpers.rb +2 -0
- data/lib/action_view/layouts.rb +8 -8
- data/lib/action_view/log_subscriber.rb +57 -36
- data/lib/action_view/lookup_context.rb +29 -13
- data/lib/action_view/path_registry.rb +57 -0
- data/lib/action_view/path_set.rb +13 -14
- data/lib/action_view/railtie.rb +25 -3
- data/lib/action_view/record_identifier.rb +15 -8
- data/lib/action_view/render_parser/prism_render_parser.rb +127 -0
- data/lib/action_view/render_parser/ripper_render_parser.rb +341 -0
- data/lib/action_view/render_parser.rb +21 -169
- data/lib/action_view/renderer/abstract_renderer.rb +2 -2
- data/lib/action_view/renderer/collection_renderer.rb +10 -2
- data/lib/action_view/renderer/partial_renderer/collection_caching.rb +2 -1
- data/lib/action_view/renderer/partial_renderer.rb +2 -1
- data/lib/action_view/renderer/renderer.rb +34 -38
- data/lib/action_view/renderer/streaming_template_renderer.rb +3 -2
- data/lib/action_view/renderer/template_renderer.rb +3 -2
- data/lib/action_view/rendering.rb +26 -8
- data/lib/action_view/template/error.rb +14 -1
- 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 +73 -1
- data/lib/action_view/template/handlers.rb +1 -1
- data/lib/action_view/template/html.rb +1 -1
- data/lib/action_view/template/raw_file.rb +1 -1
- data/lib/action_view/template/renderable.rb +8 -2
- data/lib/action_view/template/resolver.rb +9 -3
- data/lib/action_view/template/text.rb +1 -1
- data/lib/action_view/template/types.rb +25 -34
- data/lib/action_view/template.rb +268 -55
- data/lib/action_view/template_path.rb +2 -0
- data/lib/action_view/test_case.rb +181 -28
- data/lib/action_view/unbound_template.rb +17 -7
- data/lib/action_view/version.rb +1 -1
- data/lib/action_view/view_paths.rb +15 -24
- data/lib/action_view.rb +4 -1
- metadata +28 -28
- data/lib/action_view/ripper_ast_parser.rb +0 -198
- data/lib/assets/compiled/rails-ujs.js +0 -777
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "ripper"
|
|
4
|
-
|
|
5
|
-
module ActionView
|
|
6
|
-
class RenderParser
|
|
7
|
-
module RipperASTParser # :nodoc:
|
|
8
|
-
class Node < ::Array # :nodoc:
|
|
9
|
-
attr_reader :type
|
|
10
|
-
|
|
11
|
-
def initialize(type, arr, opts = {})
|
|
12
|
-
@type = type
|
|
13
|
-
super(arr)
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def children
|
|
17
|
-
to_a
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def inspect
|
|
21
|
-
typeinfo = type && type != :list ? ":" + type.to_s + ", " : ""
|
|
22
|
-
"s(" + typeinfo + map(&:inspect).join(", ") + ")"
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def fcall?
|
|
26
|
-
type == :command || type == :fcall
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def fcall_named?(name)
|
|
30
|
-
fcall? &&
|
|
31
|
-
self[0].type == :@ident &&
|
|
32
|
-
self[0][0] == name
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
def argument_nodes
|
|
36
|
-
raise unless fcall?
|
|
37
|
-
return [] if self[1].nil?
|
|
38
|
-
if self[1].last == false || self[1].last.type == :vcall
|
|
39
|
-
self[1][0...-1]
|
|
40
|
-
else
|
|
41
|
-
self[1][0..-1]
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
def string?
|
|
46
|
-
type == :string_literal
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
def variable_reference?
|
|
50
|
-
type == :var_ref
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
def vcall?
|
|
54
|
-
type == :vcall
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
def call?
|
|
58
|
-
type == :call
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
def variable_name
|
|
62
|
-
self[0][0]
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
def call_method_name
|
|
66
|
-
self.last.first
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
def to_string
|
|
70
|
-
raise unless string?
|
|
71
|
-
self[0][0][0]
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
def hash?
|
|
75
|
-
type == :bare_assoc_hash || type == :hash
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
def to_hash
|
|
79
|
-
if type == :bare_assoc_hash
|
|
80
|
-
hash_from_body(self[0])
|
|
81
|
-
elsif type == :hash && self[0] == nil
|
|
82
|
-
{}
|
|
83
|
-
elsif type == :hash && self[0].type == :assoclist_from_args
|
|
84
|
-
hash_from_body(self[0][0])
|
|
85
|
-
end
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
def hash_from_body(body)
|
|
89
|
-
body.map do |hash_node|
|
|
90
|
-
return nil if hash_node.type != :assoc_new
|
|
91
|
-
|
|
92
|
-
[hash_node[0], hash_node[1]]
|
|
93
|
-
end.to_h
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
def symbol?
|
|
97
|
-
type == :@label || type == :symbol_literal
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
def to_symbol
|
|
101
|
-
if type == :@label && self[0] =~ /\A(.+):\z/
|
|
102
|
-
$1.to_sym
|
|
103
|
-
elsif type == :symbol_literal && self[0].type == :symbol && self[0][0].type == :@ident
|
|
104
|
-
self[0][0][0].to_sym
|
|
105
|
-
else
|
|
106
|
-
raise "not a symbol?: #{self.inspect}"
|
|
107
|
-
end
|
|
108
|
-
end
|
|
109
|
-
end
|
|
110
|
-
|
|
111
|
-
class NodeParser < ::Ripper # :nodoc:
|
|
112
|
-
PARSER_EVENTS.each do |event|
|
|
113
|
-
arity = PARSER_EVENT_TABLE[event]
|
|
114
|
-
if arity == 0 && event.to_s.end_with?("_new")
|
|
115
|
-
module_eval(<<-eof, __FILE__, __LINE__ + 1)
|
|
116
|
-
def on_#{event}(*args)
|
|
117
|
-
Node.new(:list, args, lineno: lineno(), column: column())
|
|
118
|
-
end
|
|
119
|
-
eof
|
|
120
|
-
elsif event.to_s.match?(/_add(_.+)?\z/)
|
|
121
|
-
module_eval(<<-eof, __FILE__, __LINE__ + 1)
|
|
122
|
-
begin; undef on_#{event}; rescue NameError; end
|
|
123
|
-
def on_#{event}(list, item)
|
|
124
|
-
list.push(item)
|
|
125
|
-
list
|
|
126
|
-
end
|
|
127
|
-
eof
|
|
128
|
-
else
|
|
129
|
-
module_eval(<<-eof, __FILE__, __LINE__ + 1)
|
|
130
|
-
begin; undef on_#{event}; rescue NameError; end
|
|
131
|
-
def on_#{event}(*args)
|
|
132
|
-
Node.new(:#{event}, args, lineno: lineno(), column: column())
|
|
133
|
-
end
|
|
134
|
-
eof
|
|
135
|
-
end
|
|
136
|
-
end
|
|
137
|
-
|
|
138
|
-
SCANNER_EVENTS.each do |event|
|
|
139
|
-
module_eval(<<-End, __FILE__, __LINE__ + 1)
|
|
140
|
-
def on_#{event}(tok)
|
|
141
|
-
Node.new(:@#{event}, [tok], lineno: lineno(), column: column())
|
|
142
|
-
end
|
|
143
|
-
End
|
|
144
|
-
end
|
|
145
|
-
end
|
|
146
|
-
|
|
147
|
-
class RenderCallExtractor < NodeParser # :nodoc:
|
|
148
|
-
attr_reader :render_calls
|
|
149
|
-
|
|
150
|
-
METHODS_TO_PARSE = %w(render render_to_string)
|
|
151
|
-
|
|
152
|
-
def initialize(*args)
|
|
153
|
-
super
|
|
154
|
-
|
|
155
|
-
@render_calls = []
|
|
156
|
-
end
|
|
157
|
-
|
|
158
|
-
private
|
|
159
|
-
def on_fcall(name, *args)
|
|
160
|
-
on_render_call(super)
|
|
161
|
-
end
|
|
162
|
-
|
|
163
|
-
def on_command(name, *args)
|
|
164
|
-
on_render_call(super)
|
|
165
|
-
end
|
|
166
|
-
|
|
167
|
-
def on_render_call(node)
|
|
168
|
-
METHODS_TO_PARSE.each do |method|
|
|
169
|
-
if node.fcall_named?(method)
|
|
170
|
-
@render_calls << [method, node]
|
|
171
|
-
return node
|
|
172
|
-
end
|
|
173
|
-
end
|
|
174
|
-
node
|
|
175
|
-
end
|
|
176
|
-
|
|
177
|
-
def on_arg_paren(content)
|
|
178
|
-
content
|
|
179
|
-
end
|
|
180
|
-
|
|
181
|
-
def on_paren(content)
|
|
182
|
-
content
|
|
183
|
-
end
|
|
184
|
-
end
|
|
185
|
-
|
|
186
|
-
extend self
|
|
187
|
-
|
|
188
|
-
def parse_render_nodes(code)
|
|
189
|
-
parser = RenderCallExtractor.new(code)
|
|
190
|
-
parser.parse
|
|
191
|
-
|
|
192
|
-
parser.render_calls.group_by(&:first).collect do |method, nodes|
|
|
193
|
-
[ method.to_sym, nodes.collect { |v| v[1] } ]
|
|
194
|
-
end.to_h
|
|
195
|
-
end
|
|
196
|
-
end
|
|
197
|
-
end
|
|
198
|
-
end
|