actionview 7.2.1 → 8.0.0.beta1
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 +13 -99
- data/lib/action_view/dependency_tracker/erb_tracker.rb +35 -27
- data/lib/action_view/dependency_tracker/ruby_tracker.rb +2 -19
- data/lib/action_view/dependency_tracker/wildcard_resolver.rb +32 -0
- data/lib/action_view/dependency_tracker.rb +1 -0
- data/lib/action_view/gem_version.rb +4 -4
- data/lib/action_view/helpers/cache_helper.rb +8 -0
- data/lib/action_view/helpers/form_helper.rb +59 -60
- data/lib/action_view/helpers/form_options_helper.rb +16 -14
- data/lib/action_view/helpers/form_tag_helper.rb +18 -16
- data/lib/action_view/helpers/rendering_helper.rb +160 -50
- data/lib/action_view/helpers/tag_helper.rb +41 -38
- data/lib/action_view/helpers/tags/collection_check_boxes.rb +4 -3
- data/lib/action_view/helpers/url_helper.rb +3 -3
- data/lib/action_view/layouts.rb +1 -1
- data/lib/action_view/render_parser/prism_render_parser.rb +13 -1
- data/lib/action_view/render_parser/ripper_render_parser.rb +10 -1
- data/lib/action_view/renderer/streaming_template_renderer.rb +0 -1
- data/lib/action_view/rendering.rb +2 -3
- data/lib/action_view/template/resolver.rb +0 -1
- data/lib/action_view/template.rb +0 -1
- metadata +17 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dec233fd596879151b606bffdbf29f2f8c46fe41675eeb91744d352265254b9d
|
4
|
+
data.tar.gz: 3623f09bcc8011ac7e69c90d6839f3b8580f0c7c374fd3c2b1261ea4de7bd9d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: daaae5e335bf7ba563dcf6db84459ee1cdf02053b2f6ae1a9b6422174d338947c47b33cb595db8e641534064d47f1129f07ee4eb72945b933851ed0562a5fc81
|
7
|
+
data.tar.gz: 67fccc917c86e90ad9201ed67d98e45709c7433a84a80adcf126ecd9b1044ccd72aafa23587e4bada689f9ff2e41f3a21bc51ea8b7e9a11f1af7c6b57a5fee16
|
data/CHANGELOG.md
CHANGED
@@ -1,113 +1,27 @@
|
|
1
|
-
## Rails
|
1
|
+
## Rails 8.0.0.beta1 (September 26, 2024) ##
|
2
2
|
|
3
|
-
*
|
3
|
+
* Enable DependencyTracker to evaluate renders with trailing interpolation.
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
* Fix templates with strict locals to also include `local_assigns`.
|
9
|
-
|
10
|
-
Previously templates defining strict locals wouldn't receive the `local_assigns`
|
11
|
-
hash.
|
12
|
-
|
13
|
-
*Jean Boussier*
|
14
|
-
|
15
|
-
* Add queries count to template rendering instrumentation.
|
16
|
-
|
17
|
-
```
|
18
|
-
# Before
|
19
|
-
Completed 200 OK in 3804ms (Views: 41.0ms | ActiveRecord: 33.5ms | Allocations: 112788)
|
20
|
-
|
21
|
-
# After
|
22
|
-
Completed 200 OK in 3804ms (Views: 41.0ms | ActiveRecord: 33.5ms (2 queries, 1 cached) | Allocations: 112788)
|
5
|
+
```erb
|
6
|
+
<%= render "maintenance_tasks/runs/info/#{run.status}" %>
|
23
7
|
```
|
24
8
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
*Sean Doyle*
|
30
|
-
|
31
|
-
* Add the `nonce: true` option for `stylesheet_link_tag` helper to support automatic nonce generation for Content Security Policy.
|
32
|
-
|
33
|
-
Works the same way as `javascript_include_tag nonce: true` does.
|
34
|
-
|
35
|
-
*Akhil G Krishnan*, *AJ Esler*
|
36
|
-
|
37
|
-
* Parse `ActionView::TestCase#rendered` HTML content as `Nokogiri::XML::DocumentFragment` instead of `Nokogiri::XML::Document`.
|
38
|
-
|
39
|
-
*Sean Doyle*
|
40
|
-
|
41
|
-
* Rename `ActionView::TestCase::Behavior::Content` to `ActionView::TestCase::Behavior::RenderedViewContent`.
|
42
|
-
|
43
|
-
Make `RenderedViewContent` inherit from `String`. Make private API with `:nodoc:`
|
44
|
-
|
45
|
-
*Sean Doyle*
|
46
|
-
|
47
|
-
* Deprecate passing `nil` as value for the `model:` argument to the `form_with` method.
|
48
|
-
|
49
|
-
*Collin Jilbert*
|
50
|
-
|
51
|
-
* Alias `field_set_tag` helper to `fieldset_tag` to match `<fieldset>` element.
|
52
|
-
|
53
|
-
*Sean Doyle*
|
54
|
-
|
55
|
-
* Deprecate passing content to void elements when using `tag.br` type tag builders.
|
9
|
+
Previously, the DependencyTracker would ignore this render, but now it will
|
10
|
+
mark all partials in the "maintenance_tasks/runs/info" folder as
|
11
|
+
dependencies.
|
56
12
|
|
57
13
|
*Hartley McGuire*
|
58
14
|
|
59
|
-
*
|
60
|
-
|
61
|
-
*Earlopain*
|
15
|
+
* Rename `text_area` methods into `textarea`
|
62
16
|
|
63
|
-
|
17
|
+
Old names are still available as aliases.
|
64
18
|
|
65
|
-
|
66
|
-
|
67
|
-
Now they are only passed if the template will actually accept them.
|
68
|
-
|
69
|
-
*Yasha Krasnou*, *Jean Boussier*
|
70
|
-
|
71
|
-
* Fix `@rails/ujs` calling `start()` an extra time when using bundlers.
|
72
|
-
|
73
|
-
*Hartley McGuire*, *Ryunosuke Sato*
|
19
|
+
*Sean Doyle*
|
74
20
|
|
75
|
-
*
|
21
|
+
* Rename `check_box*` methods into `checkbox*`.
|
76
22
|
|
77
|
-
|
78
|
-
it would instead return the entire buffer.
|
23
|
+
Old names are still available as aliases.
|
79
24
|
|
80
25
|
*Jean Boussier*
|
81
26
|
|
82
|
-
|
83
|
-
|
84
|
-
This fix was already landed in >= 7.0.4.3, < 7.1.0.
|
85
|
-
[[CVE-2023-23913](https://github.com/advisories/GHSA-xp5h-f8jf-rc8q)]
|
86
|
-
|
87
|
-
*Ryunosuke Sato*
|
88
|
-
|
89
|
-
* Added validation for HTML tag names in the `tag` and `content_tag` helper method.
|
90
|
-
|
91
|
-
The `tag` and `content_tag` method now checks that the provided tag name adheres to the HTML
|
92
|
-
specification. If an invalid HTML tag name is provided, the method raises an `ArgumentError`
|
93
|
-
with an appropriate error message.
|
94
|
-
|
95
|
-
Examples:
|
96
|
-
|
97
|
-
```ruby
|
98
|
-
# Raises ArgumentError: Invalid HTML5 tag name: 12p
|
99
|
-
content_tag("12p") # Starting with a number
|
100
|
-
|
101
|
-
# Raises ArgumentError: Invalid HTML5 tag name: ""
|
102
|
-
content_tag("") # Empty tag name
|
103
|
-
|
104
|
-
# Raises ArgumentError: Invalid HTML5 tag name: div/
|
105
|
-
tag("div/") # Contains a solidus
|
106
|
-
|
107
|
-
# Raises ArgumentError: Invalid HTML5 tag name: "image file"
|
108
|
-
tag("image file") # Contains a space
|
109
|
-
```
|
110
|
-
|
111
|
-
*Akhil G Krishnan*
|
112
|
-
|
113
|
-
Please check [7-1-stable](https://github.com/rails/rails/blob/7-1-stable/actionview/CHANGELOG.md) for previous changes.
|
27
|
+
Please check [7-2-stable](https://github.com/rails/rails/blob/7-2-stable/actionview/CHANGELOG.md) for previous changes.
|
@@ -74,7 +74,7 @@ module ActionView
|
|
74
74
|
end
|
75
75
|
|
76
76
|
def dependencies
|
77
|
-
render_dependencies + explicit_dependencies
|
77
|
+
WildcardResolver.new(@view_paths, render_dependencies + explicit_dependencies).resolve
|
78
78
|
end
|
79
79
|
|
80
80
|
attr_reader :name, :template
|
@@ -90,15 +90,15 @@ module ActionView
|
|
90
90
|
end
|
91
91
|
|
92
92
|
def render_dependencies
|
93
|
-
|
93
|
+
dependencies = []
|
94
94
|
render_calls = source.split(/\brender\b/).drop(1)
|
95
95
|
|
96
96
|
render_calls.each do |arguments|
|
97
|
-
add_dependencies(
|
98
|
-
add_dependencies(
|
97
|
+
add_dependencies(dependencies, arguments, LAYOUT_DEPENDENCY)
|
98
|
+
add_dependencies(dependencies, arguments, RENDER_ARGUMENTS)
|
99
99
|
end
|
100
100
|
|
101
|
-
|
101
|
+
dependencies
|
102
102
|
end
|
103
103
|
|
104
104
|
def add_dependencies(render_dependencies, arguments, pattern)
|
@@ -116,12 +116,36 @@ module ActionView
|
|
116
116
|
end
|
117
117
|
|
118
118
|
def add_static_dependency(dependencies, dependency, quote_type)
|
119
|
-
if quote_type == '"'
|
120
|
-
|
121
|
-
|
122
|
-
|
119
|
+
if quote_type == '"' && dependency.include?('#{')
|
120
|
+
scanner = StringScanner.new(dependency)
|
121
|
+
|
122
|
+
wildcard_dependency = +""
|
123
|
+
|
124
|
+
while !scanner.eos?
|
125
|
+
if scanner.scan_until(/\#{/)
|
126
|
+
unmatched_brackets = 1
|
127
|
+
wildcard_dependency << scanner.pre_match
|
128
|
+
|
129
|
+
while unmatched_brackets > 0 && !scanner.eos?
|
130
|
+
scanner.scan_until(/[{}]/)
|
131
|
+
|
132
|
+
case scanner.matched
|
133
|
+
when "{"
|
134
|
+
unmatched_brackets += 1
|
135
|
+
when "}"
|
136
|
+
unmatched_brackets -= 1
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
wildcard_dependency << "*"
|
141
|
+
else
|
142
|
+
wildcard_dependency << scanner.rest
|
143
|
+
scanner.terminate
|
144
|
+
end
|
145
|
+
end
|
123
146
|
|
124
|
-
|
147
|
+
dependencies << wildcard_dependency
|
148
|
+
elsif dependency
|
125
149
|
if dependency.include?("/")
|
126
150
|
dependencies << dependency
|
127
151
|
else
|
@@ -130,24 +154,8 @@ module ActionView
|
|
130
154
|
end
|
131
155
|
end
|
132
156
|
|
133
|
-
def resolve_directories(wildcard_dependencies)
|
134
|
-
return [] unless @view_paths
|
135
|
-
return [] if wildcard_dependencies.empty?
|
136
|
-
|
137
|
-
# Remove trailing "/*"
|
138
|
-
prefixes = wildcard_dependencies.map { |query| query[0..-3] }
|
139
|
-
|
140
|
-
@view_paths.flat_map(&:all_template_paths).uniq.filter_map { |path|
|
141
|
-
path.to_s if prefixes.include?(path.prefix)
|
142
|
-
}.sort
|
143
|
-
end
|
144
|
-
|
145
157
|
def explicit_dependencies
|
146
|
-
|
147
|
-
|
148
|
-
wildcards, explicits = dependencies.partition { |dependency| dependency.end_with?("/*") }
|
149
|
-
|
150
|
-
(explicits + resolve_directories(wildcards)).uniq
|
158
|
+
source.scan(EXPLICIT_DEPENDENCY).flatten.uniq
|
151
159
|
end
|
152
160
|
end
|
153
161
|
end
|
@@ -10,7 +10,7 @@ module ActionView
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def dependencies
|
13
|
-
render_dependencies + explicit_dependencies
|
13
|
+
WildcardResolver.new(view_paths, render_dependencies + explicit_dependencies).resolve
|
14
14
|
end
|
15
15
|
|
16
16
|
def self.supports_view_paths? # :nodoc:
|
@@ -31,29 +31,12 @@ module ActionView
|
|
31
31
|
compiled_source = template.handler.call(template, template.source)
|
32
32
|
|
33
33
|
@parser_class.new(@name, compiled_source).render_calls.filter_map do |render_call|
|
34
|
-
next if render_call.end_with?("/_")
|
35
34
|
render_call.gsub(%r|/_|, "/")
|
36
35
|
end
|
37
36
|
end
|
38
37
|
|
39
38
|
def explicit_dependencies
|
40
|
-
|
41
|
-
|
42
|
-
wildcards, explicits = dependencies.partition { |dependency| dependency.end_with?("/*") }
|
43
|
-
|
44
|
-
(explicits + resolve_directories(wildcards)).uniq
|
45
|
-
end
|
46
|
-
|
47
|
-
def resolve_directories(wildcard_dependencies)
|
48
|
-
return [] unless view_paths
|
49
|
-
return [] if wildcard_dependencies.empty?
|
50
|
-
|
51
|
-
# Remove trailing "/*"
|
52
|
-
prefixes = wildcard_dependencies.map { |query| query[0..-3] }
|
53
|
-
|
54
|
-
view_paths.flat_map(&:all_template_paths).uniq.filter_map { |path|
|
55
|
-
path.to_s if prefixes.include?(path.prefix)
|
56
|
-
}.sort
|
39
|
+
template.source.scan(EXPLICIT_DEPENDENCY).flatten.uniq
|
57
40
|
end
|
58
41
|
end
|
59
42
|
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ActionView
|
4
|
+
class DependencyTracker # :nodoc:
|
5
|
+
class WildcardResolver # :nodoc:
|
6
|
+
def initialize(view_paths, dependencies)
|
7
|
+
@view_paths = view_paths
|
8
|
+
|
9
|
+
@wildcard_dependencies, @explicit_dependencies =
|
10
|
+
dependencies.partition { |dependency| dependency.end_with?("/*") }
|
11
|
+
end
|
12
|
+
|
13
|
+
def resolve
|
14
|
+
return explicit_dependencies.uniq if !view_paths || wildcard_dependencies.empty?
|
15
|
+
|
16
|
+
(explicit_dependencies + resolved_wildcard_dependencies).uniq
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
attr_reader :explicit_dependencies, :wildcard_dependencies, :view_paths
|
21
|
+
|
22
|
+
def resolved_wildcard_dependencies
|
23
|
+
# Remove trailing "/*"
|
24
|
+
prefixes = wildcard_dependencies.map { |query| query[0..-3] }
|
25
|
+
|
26
|
+
view_paths.flat_map(&:all_template_paths).uniq.filter_map { |path|
|
27
|
+
path.to_s if prefixes.include?(path.prefix)
|
28
|
+
}.sort
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -93,6 +93,14 @@ module ActionView
|
|
93
93
|
# render partial: 'attachments/attachment', collection: group_of_attachments
|
94
94
|
# render partial: 'documents/document', collection: @project.documents.where(published: true).order('created_at')
|
95
95
|
#
|
96
|
+
# One last type of dependency can be determined implicitly:
|
97
|
+
#
|
98
|
+
# render "maintenance_tasks/runs/info/#{run.status}"
|
99
|
+
#
|
100
|
+
# Because the value passed to render ends in interpolation, Action View
|
101
|
+
# will mark all partials within the "maintenace_tasks/runs/info" folder as
|
102
|
+
# dependencies.
|
103
|
+
#
|
96
104
|
# === Explicit dependencies
|
97
105
|
#
|
98
106
|
# Sometimes you'll have template dependencies that can't be derived at all. This is typically
|