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