actionview 7.1.5.1 → 7.2.2.1
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 +52 -435
- data/lib/action_view/base.rb +20 -2
- data/lib/action_view/cache_expiry.rb +9 -3
- 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/gem_version.rb +2 -2
- data/lib/action_view/helpers/asset_tag_helper.rb +15 -3
- data/lib/action_view/helpers/csrf_helper.rb +1 -1
- data/lib/action_view/helpers/form_helper.rb +197 -192
- data/lib/action_view/helpers/form_tag_helper.rb +80 -47
- data/lib/action_view/helpers/output_safety_helper.rb +4 -4
- data/lib/action_view/helpers/tag_helper.rb +208 -18
- data/lib/action_view/helpers/text_helper.rb +1 -1
- data/lib/action_view/helpers/url_helper.rb +3 -77
- data/lib/action_view/layouts.rb +2 -4
- data/lib/action_view/log_subscriber.rb +8 -4
- data/lib/action_view/railtie.rb +0 -1
- data/lib/action_view/render_parser/prism_render_parser.rb +127 -0
- data/lib/action_view/{ripper_ast_parser.rb → render_parser/ripper_render_parser.rb} +152 -9
- data/lib/action_view/render_parser.rb +21 -169
- data/lib/action_view/renderer/abstract_renderer.rb +1 -1
- data/lib/action_view/renderer/renderer.rb +32 -38
- data/lib/action_view/rendering.rb +4 -4
- data/lib/action_view/template/renderable.rb +7 -1
- data/lib/action_view/template/resolver.rb +0 -2
- data/lib/action_view/template.rb +36 -8
- data/lib/action_view/test_case.rb +7 -9
- metadata +14 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 129f00c083e1a4443010be161169e51eea090543c6618289968ed2cdb1c65c76
|
4
|
+
data.tar.gz: 568d88d12f7fc363958af2f8bf45308199dc0c221a05fafb9415a96b3eaddc8a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: de08bd40788b58e9ba6be2169a5ebbc39c6b4f1122d1564b64cf0a6af066f855d4a1ad2d1721ab849fde78ee87c496c61579afd59d1a3062dba6135b6652bee4
|
7
|
+
data.tar.gz: cf2f5461be068f0d96d287bbdabe2daf9b3d76a4e80c9db31041d9242f77986b1d5d6774d6db95f5f2b068cbce2161b13335891bfd86d271994d49321bc88733
|
data/CHANGELOG.md
CHANGED
@@ -1,88 +1,86 @@
|
|
1
|
-
## Rails 7.
|
1
|
+
## Rails 7.2.2.1 (December 10, 2024) ##
|
2
2
|
|
3
3
|
* No changes.
|
4
4
|
|
5
5
|
|
6
|
-
## Rails 7.
|
6
|
+
## Rails 7.2.2 (October 30, 2024) ##
|
7
7
|
|
8
8
|
* No changes.
|
9
9
|
|
10
10
|
|
11
|
-
## Rails 7.1.
|
11
|
+
## Rails 7.2.1.2 (October 23, 2024) ##
|
12
12
|
|
13
13
|
* No changes.
|
14
14
|
|
15
15
|
|
16
|
-
## Rails 7.1.
|
16
|
+
## Rails 7.2.1.1 (October 15, 2024) ##
|
17
17
|
|
18
18
|
* No changes.
|
19
19
|
|
20
20
|
|
21
|
-
## Rails 7.1
|
22
|
-
|
23
|
-
* Action View Test Case `rendered` memoization.
|
24
|
-
|
25
|
-
*Sean Doyle*
|
26
|
-
|
27
|
-
* Restore the ability for templates to return any kind of object and not just strings
|
28
|
-
|
29
|
-
*Jean Boussier*
|
30
|
-
|
31
|
-
* Fix threading issue with strict locals.
|
32
|
-
|
33
|
-
*Robert Fletcher*
|
34
|
-
|
35
|
-
|
36
|
-
## Rails 7.1.3.4 (June 04, 2024) ##
|
21
|
+
## Rails 7.2.1 (August 22, 2024) ##
|
37
22
|
|
38
23
|
* No changes.
|
39
24
|
|
40
25
|
|
41
|
-
## Rails 7.
|
26
|
+
## Rails 7.2.0 (August 09, 2024) ##
|
42
27
|
|
43
|
-
*
|
28
|
+
* Fix templates with strict locals to also include `local_assigns`.
|
44
29
|
|
30
|
+
Previously templates defining strict locals wouldn't receive the `local_assigns`
|
31
|
+
hash.
|
45
32
|
|
46
|
-
|
33
|
+
*Jean Boussier*
|
47
34
|
|
48
|
-
*
|
35
|
+
* Add queries count to template rendering instrumentation.
|
49
36
|
|
37
|
+
```
|
38
|
+
# Before
|
39
|
+
Completed 200 OK in 3804ms (Views: 41.0ms | ActiveRecord: 33.5ms | Allocations: 112788)
|
50
40
|
|
51
|
-
|
41
|
+
# After
|
42
|
+
Completed 200 OK in 3804ms (Views: 41.0ms | ActiveRecord: 33.5ms (2 queries, 1 cached) | Allocations: 112788)
|
43
|
+
```
|
52
44
|
|
53
|
-
*
|
45
|
+
*fatkodima*
|
54
46
|
|
47
|
+
* Raise `ArgumentError` if `:renderable` object does not respond to `#render_in`.
|
55
48
|
|
56
|
-
|
49
|
+
*Sean Doyle*
|
50
|
+
|
51
|
+
* Add the `nonce: true` option for `stylesheet_link_tag` helper to support automatic nonce generation for Content Security Policy.
|
57
52
|
|
58
|
-
|
53
|
+
Works the same way as `javascript_include_tag nonce: true` does.
|
59
54
|
|
60
|
-
*
|
55
|
+
*Akhil G Krishnan*, *AJ Esler*
|
61
56
|
|
62
|
-
*
|
57
|
+
* Parse `ActionView::TestCase#rendered` HTML content as `Nokogiri::XML::DocumentFragment` instead of `Nokogiri::XML::Document`.
|
63
58
|
|
64
|
-
*
|
59
|
+
*Sean Doyle*
|
65
60
|
|
66
61
|
* Rename `ActionView::TestCase::Behavior::Content` to `ActionView::TestCase::Behavior::RenderedViewContent`.
|
67
62
|
|
68
|
-
Make `RenderedViewContent` inherit from `String`. Make private API with `:nodoc
|
63
|
+
Make `RenderedViewContent` inherit from `String`. Make private API with `:nodoc:`
|
69
64
|
|
70
65
|
*Sean Doyle*
|
71
66
|
|
72
|
-
*
|
67
|
+
* Deprecate passing `nil` as value for the `model:` argument to the `form_with` method.
|
73
68
|
|
74
|
-
|
69
|
+
*Collin Jilbert*
|
75
70
|
|
76
|
-
|
71
|
+
* Alias `field_set_tag` helper to `fieldset_tag` to match `<fieldset>` element.
|
72
|
+
|
73
|
+
*Sean Doyle*
|
77
74
|
|
75
|
+
* Deprecate passing content to void elements when using `tag.br` type tag builders.
|
78
76
|
|
79
|
-
|
77
|
+
*Hartley McGuire*
|
80
78
|
|
81
79
|
* Fix the `number_to_human_size` view helper to correctly work with negative numbers.
|
82
80
|
|
83
81
|
*Earlopain*
|
84
82
|
|
85
|
-
* Automatically discard the implicit locals injected by collection rendering for template that can't accept them
|
83
|
+
* Automatically discard the implicit locals injected by collection rendering for template that can't accept them.
|
86
84
|
|
87
85
|
When rendering a collection, two implicit variables are injected, which breaks templates with strict locals.
|
88
86
|
|
@@ -90,20 +88,17 @@
|
|
90
88
|
|
91
89
|
*Yasha Krasnou*, *Jean Boussier*
|
92
90
|
|
93
|
-
* Fix `@rails/ujs` calling `start()` an extra time when using bundlers
|
91
|
+
* Fix `@rails/ujs` calling `start()` an extra time when using bundlers.
|
94
92
|
|
95
93
|
*Hartley McGuire*, *Ryunosuke Sato*
|
96
94
|
|
97
|
-
* Fix the `capture` view helper compatibility with HAML and Slim
|
95
|
+
* Fix the `capture` view helper compatibility with HAML and Slim.
|
98
96
|
|
99
97
|
When a blank string was captured in HAML or Slim (and possibly other template engines)
|
100
98
|
it would instead return the entire buffer.
|
101
99
|
|
102
100
|
*Jean Boussier*
|
103
101
|
|
104
|
-
|
105
|
-
## Rails 7.1.1 (October 11, 2023) ##
|
106
|
-
|
107
102
|
* Updated `@rails/ujs` files to ignore certain data-* attributes when element is contenteditable.
|
108
103
|
|
109
104
|
This fix was already landed in >= 7.0.4.3, < 7.1.0.
|
@@ -111,406 +106,28 @@
|
|
111
106
|
|
112
107
|
*Ryunosuke Sato*
|
113
108
|
|
109
|
+
* Added validation for HTML tag names in the `tag` and `content_tag` helper method.
|
114
110
|
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
## Rails 7.1.0.rc2 (October 01, 2023) ##
|
121
|
-
|
122
|
-
* No changes.
|
123
|
-
|
124
|
-
|
125
|
-
## Rails 7.1.0.rc1 (September 27, 2023) ##
|
126
|
-
|
127
|
-
* Introduce `ActionView::TestCase.register_parser`
|
128
|
-
|
129
|
-
```ruby
|
130
|
-
register_parser :rss, -> rendered { RSS::Parser.parse(rendered) }
|
131
|
-
|
132
|
-
test "renders RSS" do
|
133
|
-
article = Article.create!(title: "Hello, world")
|
134
|
-
|
135
|
-
render formats: :rss, partial: article
|
136
|
-
|
137
|
-
assert_equal "Hello, world", rendered.rss.items.last.title
|
138
|
-
end
|
139
|
-
```
|
140
|
-
|
141
|
-
By default, register parsers for `:html` and `:json`.
|
142
|
-
|
143
|
-
*Sean Doyle*
|
144
|
-
|
145
|
-
|
146
|
-
## Rails 7.1.0.beta1 (September 13, 2023) ##
|
147
|
-
|
148
|
-
* Fix `simple_format` with blank `wrapper_tag` option returns plain html tag
|
149
|
-
|
150
|
-
By default `simple_format` method returns the text wrapped with `<p>`. But if we explicitly specify
|
151
|
-
the `wrapper_tag: nil` in the options, it returns the text wrapped with `<></>` tag.
|
152
|
-
|
153
|
-
Before:
|
154
|
-
|
155
|
-
```ruby
|
156
|
-
simple_format("Hello World", {}, { wrapper_tag: nil })
|
157
|
-
# <>Hello World</>
|
158
|
-
```
|
159
|
-
|
160
|
-
After:
|
161
|
-
|
162
|
-
```ruby
|
163
|
-
simple_format("Hello World", {}, { wrapper_tag: nil })
|
164
|
-
# <p>Hello World</p>
|
165
|
-
```
|
166
|
-
|
167
|
-
*Akhil G Krishnan*, *Junichi Ito*
|
168
|
-
|
169
|
-
* Don't double-encode nested `field_id` and `field_name` index values
|
170
|
-
|
171
|
-
Pass `index: @options` as a default keyword argument to `field_id` and
|
172
|
-
`field_name` view helper methods.
|
173
|
-
|
174
|
-
*Sean Doyle*
|
175
|
-
|
176
|
-
* Allow opting in/out of `Link preload` headers when calling `stylesheet_link_tag` or `javascript_include_tag`
|
177
|
-
|
178
|
-
```ruby
|
179
|
-
# will exclude header, even if setting is enabled:
|
180
|
-
javascript_include_tag("http://example.com/all.js", preload_links_header: false)
|
181
|
-
|
182
|
-
# will include header, even if setting is disabled:
|
183
|
-
stylesheet_link_tag("http://example.com/all.js", preload_links_header: true)
|
184
|
-
```
|
185
|
-
|
186
|
-
*Alex Ghiculescu*
|
187
|
-
|
188
|
-
* Stop generating `Link preload` headers once it has reached 1KB.
|
189
|
-
|
190
|
-
Some proxies have trouble handling large headers, but more importantly preload links
|
191
|
-
have diminishing returns so it's preferable not to go overboard with them.
|
192
|
-
|
193
|
-
If tighter control is needed, it's recommended to disable automatic generation of preloads
|
194
|
-
and to generate them manually from the controller or from a middleware.
|
195
|
-
|
196
|
-
*Jean Boussier*
|
197
|
-
|
198
|
-
* `simple_format` helper now handles a `:sanitize_options` - any extra options you want appending to the sanitize.
|
199
|
-
|
200
|
-
Before:
|
201
|
-
```ruby
|
202
|
-
simple_format("<a target=\"_blank\" href=\"http://example.com\">Continue</a>")
|
203
|
-
# => "<p><a href=\"http://example.com\">Continue</a></p>"
|
204
|
-
```
|
205
|
-
|
206
|
-
After:
|
207
|
-
```ruby
|
208
|
-
simple_format("<a target=\"_blank\" href=\"http://example.com\">Continue</a>", {}, { sanitize_options: { attributes: %w[target href] } })
|
209
|
-
# => "<p><a target=\"_blank\" href=\"http://example.com\">Continue</a></p>"
|
210
|
-
```
|
211
|
-
|
212
|
-
*Andrei Andriichuk*
|
213
|
-
|
214
|
-
* Add support for HTML5 standards-compliant sanitizers, and default to `Rails::HTML5::Sanitizer`
|
215
|
-
in the Rails 7.1 configuration if it is supported.
|
216
|
-
|
217
|
-
Action View's HTML sanitizers can be configured by setting
|
218
|
-
`config.action_view.sanitizer_vendor`. Supported values are `Rails::HTML4::Sanitizer` or
|
219
|
-
`Rails::HTML5::Sanitizer`.
|
220
|
-
|
221
|
-
The Rails 7.1 configuration will set this to `Rails::HTML5::Sanitizer` when it is supported, and
|
222
|
-
fall back to `Rails::HTML4::Sanitizer`. Previous configurations default to
|
223
|
-
`Rails::HTML4::Sanitizer`.
|
224
|
-
|
225
|
-
*Mike Dalessio*
|
226
|
-
|
227
|
-
* `config.dom_testing_default_html_version` controls the HTML parser used by
|
228
|
-
`ActionView::TestCase#document_root_element`, which creates the DOM used by the assertions in
|
229
|
-
Rails::Dom::Testing.
|
230
|
-
|
231
|
-
The Rails 7.1 default configuration opts into the HTML5 parser when it is supported, to better
|
232
|
-
represent what the DOM would be in a browser user agent. Previously this test helper always used
|
233
|
-
Nokogiri's HTML4 parser.
|
234
|
-
|
235
|
-
*Mike Dalessio*
|
236
|
-
|
237
|
-
* Add support for the HTML picture tag. It supports passing a String, an Array or a Block.
|
238
|
-
Supports passing properties directly to the img tag via the `:image` key.
|
239
|
-
Since the picture tag requires an img tag, the last element you provide will be used for the img tag.
|
240
|
-
For complete control over the picture tag, a block can be passed, which will populate the contents of the tag accordingly.
|
241
|
-
|
242
|
-
Can be used like this for a single source:
|
243
|
-
```erb
|
244
|
-
<%= picture_tag("picture.webp") %>
|
245
|
-
```
|
246
|
-
which will generate the following:
|
247
|
-
```html
|
248
|
-
<picture>
|
249
|
-
<img src="/images/picture.webp" />
|
250
|
-
</picture>
|
251
|
-
```
|
252
|
-
|
253
|
-
For multiple sources:
|
254
|
-
```erb
|
255
|
-
<%= picture_tag("picture.webp", "picture.png", :class => "mt-2", :image => { alt: "Image", class: "responsive-img" }) %>
|
256
|
-
```
|
257
|
-
will generate:
|
258
|
-
```html
|
259
|
-
<picture class="mt-2">
|
260
|
-
<source srcset="/images/picture.webp" />
|
261
|
-
<source srcset="/images/picture.png" />
|
262
|
-
<img alt="Image" class="responsive-img" src="/images/picture.png" />
|
263
|
-
</picture>
|
264
|
-
```
|
265
|
-
|
266
|
-
Full control via a block:
|
267
|
-
```erb
|
268
|
-
<%= picture_tag(:class => "my-class") do %>
|
269
|
-
<%= tag(:source, :srcset => image_path("picture.webp")) %>
|
270
|
-
<%= tag(:source, :srcset => image_path("picture.png")) %>
|
271
|
-
<%= image_tag("picture.png", :alt => "Image") %>
|
272
|
-
<% end %>
|
273
|
-
```
|
274
|
-
will generate:
|
275
|
-
```html
|
276
|
-
<picture class="my-class">
|
277
|
-
<source srcset="/images/picture.webp" />
|
278
|
-
<source srcset="/images/picture.png" />
|
279
|
-
<img alt="Image" src="/images/picture.png" />
|
280
|
-
</picture>
|
281
|
-
```
|
282
|
-
|
283
|
-
*Juan Pablo Balarini*
|
284
|
-
|
285
|
-
* Remove deprecated support to passing instance variables as locals to partials.
|
111
|
+
The `tag` and `content_tag` method now checks that the provided tag name adheres to the HTML
|
112
|
+
specification. If an invalid HTML tag name is provided, the method raises an `ArgumentError`
|
113
|
+
with an appropriate error message.
|
286
114
|
|
287
|
-
|
115
|
+
Examples:
|
288
116
|
|
289
|
-
* Remove deprecated constant `ActionView::Path`.
|
290
|
-
|
291
|
-
*Rafael Mendonça França*
|
292
|
-
|
293
|
-
* Guard `token_list` calls from escaping HTML too often
|
294
|
-
|
295
|
-
*Sean Doyle*
|
296
|
-
|
297
|
-
* `select` can now be called with a single hash containing options and some HTML options
|
298
|
-
|
299
|
-
Previously this would not work as expected:
|
300
|
-
|
301
|
-
```erb
|
302
|
-
<%= select :post, :author, authors, required: true %>
|
303
|
-
```
|
304
|
-
|
305
|
-
Instead you needed to do this:
|
306
|
-
|
307
|
-
```erb
|
308
|
-
<%= select :post, :author, authors, {}, required: true %>
|
309
|
-
```
|
310
|
-
|
311
|
-
Now, either form is accepted, for the following HTML attributes: `required`, `multiple`, `size`.
|
312
|
-
|
313
|
-
*Alex Ghiculescu*
|
314
|
-
|
315
|
-
* Datetime form helpers (`time_field`, `date_field`, `datetime_field`, `week_field`, `month_field`) now accept an instance of Time/Date/DateTime as `:value` option.
|
316
|
-
|
317
|
-
Before:
|
318
|
-
```erb
|
319
|
-
<%= form.datetime_field :written_at, value: Time.current.strftime("%Y-%m-%dT%T") %>
|
320
|
-
```
|
321
|
-
|
322
|
-
After:
|
323
|
-
```erb
|
324
|
-
<%= form.datetime_field :written_at, value: Time.current %>
|
325
|
-
```
|
326
|
-
|
327
|
-
*Andrey Samsonov*
|
328
|
-
|
329
|
-
* Choices of `select` can optionally contain html attributes as the last element
|
330
|
-
of the child arrays when using grouped/nested collections
|
331
|
-
|
332
|
-
```erb
|
333
|
-
<%= form.select :foo, [["North America", [["United States","US"],["Canada","CA"]], { disabled: "disabled" }]] %>
|
334
|
-
# => <select><optgroup label="North America" disabled="disabled"><option value="US">United States</option><option value="CA">Canada</option></optgroup></select>
|
335
|
-
```
|
336
|
-
|
337
|
-
*Chris Gunther*
|
338
|
-
|
339
|
-
* `check_box_tag` and `radio_button_tag` now accept `checked` as a keyword argument
|
340
|
-
|
341
|
-
This is to make the API more consistent with the `FormHelper` variants. You can now
|
342
|
-
provide `checked` as a positional or keyword argument:
|
343
|
-
|
344
|
-
```erb
|
345
|
-
= check_box_tag "admin", "1", false
|
346
|
-
= check_box_tag "admin", "1", checked: false
|
347
|
-
|
348
|
-
= radio_button_tag 'favorite_color', 'maroon', false
|
349
|
-
= radio_button_tag 'favorite_color', 'maroon', checked: false
|
350
|
-
```
|
351
|
-
|
352
|
-
*Alex Ghiculescu*
|
353
|
-
|
354
|
-
* Allow passing a class to `dom_id`.
|
355
|
-
You no longer need to call `new` when passing a class to `dom_id`.
|
356
|
-
This makes `dom_id` behave like `dom_class` in this regard.
|
357
|
-
Apart from saving a few keystrokes, it prevents Ruby from needing
|
358
|
-
to instantiate a whole new object just to generate a string.
|
359
|
-
|
360
|
-
Before:
|
361
|
-
```ruby
|
362
|
-
dom_id(Post) # => NoMethodError: undefined method `to_key' for Post:Class
|
363
|
-
```
|
364
|
-
|
365
|
-
After:
|
366
|
-
```ruby
|
367
|
-
dom_id(Post) # => "new_post"
|
368
|
-
```
|
369
|
-
|
370
|
-
*Goulven Champenois*
|
371
|
-
|
372
|
-
* Report `:locals` as part of the data returned by ActionView render instrumentation.
|
373
|
-
|
374
|
-
Before:
|
375
|
-
```ruby
|
376
|
-
{
|
377
|
-
identifier: "/Users/adam/projects/notifications/app/views/posts/index.html.erb",
|
378
|
-
layout: "layouts/application"
|
379
|
-
}
|
380
|
-
```
|
381
|
-
|
382
|
-
After:
|
383
117
|
```ruby
|
384
|
-
|
385
|
-
|
386
|
-
layout: "layouts/application",
|
387
|
-
locals: {foo: "bar"}
|
388
|
-
}
|
389
|
-
```
|
118
|
+
# Raises ArgumentError: Invalid HTML5 tag name: 12p
|
119
|
+
content_tag("12p") # Starting with a number
|
390
120
|
|
391
|
-
|
121
|
+
# Raises ArgumentError: Invalid HTML5 tag name: ""
|
122
|
+
content_tag("") # Empty tag name
|
392
123
|
|
393
|
-
|
124
|
+
# Raises ArgumentError: Invalid HTML5 tag name: div/
|
125
|
+
tag("div/") # Contains a solidus
|
394
126
|
|
395
|
-
|
396
|
-
|
397
|
-
For example, compare the outputs of this template:
|
398
|
-
|
399
|
-
```erb
|
400
|
-
# <%= word_wrap("11 22\n33 44", line_width: 2, break_sequence: "\n# ") %>
|
401
|
-
```
|
402
|
-
|
403
|
-
Before:
|
404
|
-
|
405
|
-
```
|
406
|
-
# 11
|
407
|
-
# 22
|
408
|
-
#
|
409
|
-
# 33
|
410
|
-
# 44
|
411
|
-
#
|
127
|
+
# Raises ArgumentError: Invalid HTML5 tag name: "image file"
|
128
|
+
tag("image file") # Contains a space
|
412
129
|
```
|
413
130
|
|
414
|
-
|
415
|
-
|
416
|
-
```
|
417
|
-
# 11
|
418
|
-
# 22
|
419
|
-
# 33
|
420
|
-
# 44
|
421
|
-
```
|
422
|
-
|
423
|
-
*Max Chernyak*
|
424
|
-
|
425
|
-
* Allow templates to set strict `locals`.
|
426
|
-
|
427
|
-
By default, templates will accept any `locals` as keyword arguments. To define what `locals` a template accepts, add a `locals` magic comment:
|
428
|
-
|
429
|
-
```erb
|
430
|
-
<%# locals: (message:) -%>
|
431
|
-
<%= message %>
|
432
|
-
```
|
433
|
-
|
434
|
-
Default values can also be provided:
|
435
|
-
|
436
|
-
```erb
|
437
|
-
<%# locals: (message: "Hello, world!") -%>
|
438
|
-
<%= message %>
|
439
|
-
```
|
440
|
-
|
441
|
-
Or `locals` can be disabled entirely:
|
442
|
-
|
443
|
-
```erb
|
444
|
-
<%# locals: () %>
|
445
|
-
```
|
446
|
-
|
447
|
-
*Joel Hawksley*
|
448
|
-
|
449
|
-
* Add `include_seconds` option for `datetime_local_field`
|
450
|
-
|
451
|
-
This allows to omit seconds part in the input field, by passing `include_seconds: false`
|
452
|
-
|
453
|
-
*Wojciech Wnętrzak*
|
454
|
-
|
455
|
-
* Guard against `ActionView::Helpers::FormTagHelper#field_name` calls with nil
|
456
|
-
`object_name` arguments. For example:
|
457
|
-
|
458
|
-
```erb
|
459
|
-
<%= fields do |f| %>
|
460
|
-
<%= f.field_name :body %>
|
461
|
-
<% end %>
|
462
|
-
```
|
463
|
-
|
464
|
-
*Sean Doyle*
|
465
|
-
|
466
|
-
* Strings returned from `strip_tags` are correctly tagged `html_safe?`
|
467
|
-
|
468
|
-
Because these strings contain no HTML elements and the basic entities are escaped, they are safe
|
469
|
-
to be included as-is as PCDATA in HTML content. Tagging them as html-safe avoids double-escaping
|
470
|
-
entities when being concatenated to a SafeBuffer during rendering.
|
471
|
-
|
472
|
-
Fixes [rails/rails-html-sanitizer#124](https://github.com/rails/rails-html-sanitizer/issues/124)
|
473
|
-
|
474
|
-
*Mike Dalessio*
|
475
|
-
|
476
|
-
* Move `convert_to_model` call from `form_for` into `form_with`
|
477
|
-
|
478
|
-
Now that `form_for` is implemented in terms of `form_with`, remove the
|
479
|
-
`convert_to_model` call from `form_for`.
|
480
|
-
|
481
|
-
*Sean Doyle*
|
482
|
-
|
483
|
-
* Fix and add protections for XSS in `ActionView::Helpers` and `ERB::Util`.
|
484
|
-
|
485
|
-
Escape dangerous characters in names of tags and names of attributes in the
|
486
|
-
tag helpers, following the XML specification. Rename the option
|
487
|
-
`:escape_attributes` to `:escape`, to simplify by applying the option to the
|
488
|
-
whole tag.
|
489
|
-
|
490
|
-
*Álvaro Martín Fraguas*
|
491
|
-
|
492
|
-
* Extend audio_tag and video_tag to accept Active Storage attachments.
|
493
|
-
|
494
|
-
Now it's possible to write
|
495
|
-
|
496
|
-
```ruby
|
497
|
-
audio_tag(user.audio_file)
|
498
|
-
video_tag(user.video_file)
|
499
|
-
```
|
500
|
-
|
501
|
-
Instead of
|
502
|
-
|
503
|
-
```ruby
|
504
|
-
audio_tag(polymorphic_path(user.audio_file))
|
505
|
-
video_tag(polymorphic_path(user.video_file))
|
506
|
-
```
|
507
|
-
|
508
|
-
`image_tag` already supported that, so this follows the same pattern.
|
509
|
-
|
510
|
-
*Matheus Richard*
|
511
|
-
|
512
|
-
* Ensure models passed to `form_for` attempt to call `to_model`.
|
513
|
-
|
514
|
-
*Sean Doyle*
|
131
|
+
*Akhil G Krishnan*
|
515
132
|
|
516
|
-
Please check [7-
|
133
|
+
Please check [7-1-stable](https://github.com/rails/rails/blob/7-1-stable/actionview/CHANGELOG.md) for previous changes.
|
data/lib/action_view/base.rb
CHANGED
@@ -80,6 +80,23 @@ module ActionView # :nodoc:
|
|
80
80
|
# This is useful in cases where you aren't sure if the local variable has been assigned. Alternatively, you could also use
|
81
81
|
# <tt>defined? headline</tt> to first check if the variable has been assigned before using it.
|
82
82
|
#
|
83
|
+
# By default, templates will accept any <tt>locals</tt> as keyword arguments. To restrict what <tt>locals</tt> a template accepts, add a <tt>locals:</tt> magic comment:
|
84
|
+
#
|
85
|
+
# <%# locals: (headline:) %>
|
86
|
+
#
|
87
|
+
# Headline: <%= headline %>
|
88
|
+
#
|
89
|
+
# In cases where the local variables are optional, declare the keyword argument with a default value:
|
90
|
+
#
|
91
|
+
# <%# locals: (headline: nil) %>
|
92
|
+
#
|
93
|
+
# <% unless headline.nil? %>
|
94
|
+
# Headline: <%= headline %>
|
95
|
+
# <% end %>
|
96
|
+
#
|
97
|
+
# Read more about strict locals in {Action View Overview}[https://guides.rubyonrails.org/action_view_overview.html#strict-locals]
|
98
|
+
# in the guides.
|
99
|
+
#
|
83
100
|
# === Template caching
|
84
101
|
#
|
85
102
|
# By default, \Rails will compile each template to a method in order to render it. When you alter a template,
|
@@ -248,7 +265,7 @@ module ActionView # :nodoc:
|
|
248
265
|
|
249
266
|
if has_strict_locals
|
250
267
|
begin
|
251
|
-
public_send(method, buffer, **locals, &block)
|
268
|
+
public_send(method, locals, buffer, **locals, &block)
|
252
269
|
rescue ArgumentError => argument_error
|
253
270
|
raise(
|
254
271
|
ArgumentError,
|
@@ -256,7 +273,8 @@ module ActionView # :nodoc:
|
|
256
273
|
message.
|
257
274
|
gsub("unknown keyword:", "unknown local:").
|
258
275
|
gsub("missing keyword:", "missing local:").
|
259
|
-
gsub("no keywords accepted", "no locals accepted")
|
276
|
+
gsub("no keywords accepted", "no locals accepted").
|
277
|
+
concat(" for #{@current_template.short_identifier}")
|
260
278
|
)
|
261
279
|
end
|
262
280
|
else
|
@@ -10,16 +10,17 @@ module ActionView
|
|
10
10
|
@watcher = nil
|
11
11
|
@previous_change = false
|
12
12
|
|
13
|
-
rebuild_watcher
|
14
|
-
|
15
13
|
ActionView::PathRegistry.file_system_resolver_hooks << method(:rebuild_watcher)
|
16
14
|
end
|
17
15
|
|
18
16
|
def updated?
|
17
|
+
build_watcher unless @watcher
|
19
18
|
@previous_change || @watcher.updated?
|
20
19
|
end
|
21
20
|
|
22
21
|
def execute
|
22
|
+
return unless @watcher
|
23
|
+
|
23
24
|
watcher = nil
|
24
25
|
@mutex.synchronize do
|
25
26
|
@previous_change = false
|
@@ -33,7 +34,7 @@ module ActionView
|
|
33
34
|
ActionView::LookupContext::DetailsKey.clear
|
34
35
|
end
|
35
36
|
|
36
|
-
def
|
37
|
+
def build_watcher
|
37
38
|
@mutex.synchronize do
|
38
39
|
old_watcher = @watcher
|
39
40
|
|
@@ -51,6 +52,11 @@ module ActionView
|
|
51
52
|
end
|
52
53
|
end
|
53
54
|
|
55
|
+
def rebuild_watcher
|
56
|
+
return unless @watcher
|
57
|
+
build_watcher
|
58
|
+
end
|
59
|
+
|
54
60
|
def dirs_to_watch
|
55
61
|
all_view_paths.uniq.sort
|
56
62
|
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module ActionView
|
4
4
|
class DependencyTracker # :nodoc:
|
5
|
-
class
|
5
|
+
class RubyTracker # :nodoc:
|
6
6
|
EXPLICIT_DEPENDENCY = /# Template Dependency: (\S+)/
|
7
7
|
|
8
8
|
def self.call(name, template, view_paths = nil)
|
@@ -17,8 +17,9 @@ module ActionView
|
|
17
17
|
true
|
18
18
|
end
|
19
19
|
|
20
|
-
def initialize(name, template, view_paths = nil)
|
20
|
+
def initialize(name, template, view_paths = nil, parser_class: RenderParser::Default)
|
21
21
|
@name, @template, @view_paths = name, template, view_paths
|
22
|
+
@parser_class = parser_class
|
22
23
|
end
|
23
24
|
|
24
25
|
private
|
@@ -29,7 +30,7 @@ module ActionView
|
|
29
30
|
|
30
31
|
compiled_source = template.handler.call(template, template.source)
|
31
32
|
|
32
|
-
|
33
|
+
@parser_class.new(@name, compiled_source).render_calls.filter_map do |render_call|
|
33
34
|
next if render_call.end_with?("/_")
|
34
35
|
render_call.gsub(%r|/_|, "/")
|
35
36
|
end
|