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.
Files changed (96) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +54 -439
  3. data/MIT-LICENSE +1 -1
  4. data/README.rdoc +1 -1
  5. data/app/assets/javascripts/rails-ujs.esm.js +686 -0
  6. data/app/assets/javascripts/rails-ujs.js +630 -0
  7. data/lib/action_view/base.rb +52 -14
  8. data/lib/action_view/buffers.rb +106 -8
  9. data/lib/action_view/cache_expiry.rb +44 -41
  10. data/lib/action_view/context.rb +1 -1
  11. data/lib/action_view/dependency_tracker/{ripper_tracker.rb → ruby_tracker.rb} +4 -3
  12. data/lib/action_view/dependency_tracker.rb +1 -1
  13. data/lib/action_view/deprecator.rb +7 -0
  14. data/lib/action_view/digestor.rb +1 -1
  15. data/lib/action_view/gem_version.rb +3 -3
  16. data/lib/action_view/helpers/active_model_helper.rb +1 -1
  17. data/lib/action_view/helpers/asset_tag_helper.rb +151 -55
  18. data/lib/action_view/helpers/asset_url_helper.rb +6 -5
  19. data/lib/action_view/helpers/atom_feed_helper.rb +5 -5
  20. data/lib/action_view/helpers/cache_helper.rb +7 -13
  21. data/lib/action_view/helpers/capture_helper.rb +30 -10
  22. data/lib/action_view/helpers/content_exfiltration_prevention_helper.rb +70 -0
  23. data/lib/action_view/helpers/controller_helper.rb +6 -0
  24. data/lib/action_view/helpers/csp_helper.rb +2 -2
  25. data/lib/action_view/helpers/csrf_helper.rb +3 -3
  26. data/lib/action_view/helpers/date_helper.rb +17 -19
  27. data/lib/action_view/helpers/debug_helper.rb +3 -3
  28. data/lib/action_view/helpers/form_helper.rb +248 -214
  29. data/lib/action_view/helpers/form_options_helper.rb +2 -1
  30. data/lib/action_view/helpers/form_tag_helper.rb +121 -54
  31. data/lib/action_view/helpers/javascript_helper.rb +1 -0
  32. data/lib/action_view/helpers/number_helper.rb +37 -330
  33. data/lib/action_view/helpers/output_safety_helper.rb +6 -6
  34. data/lib/action_view/helpers/rendering_helper.rb +1 -1
  35. data/lib/action_view/helpers/sanitize_helper.rb +51 -21
  36. data/lib/action_view/helpers/tag_helper.rb +210 -42
  37. data/lib/action_view/helpers/tags/base.rb +11 -52
  38. data/lib/action_view/helpers/tags/collection_check_boxes.rb +1 -0
  39. data/lib/action_view/helpers/tags/collection_radio_buttons.rb +1 -0
  40. data/lib/action_view/helpers/tags/collection_select.rb +3 -0
  41. data/lib/action_view/helpers/tags/date_field.rb +1 -1
  42. data/lib/action_view/helpers/tags/date_select.rb +2 -0
  43. data/lib/action_view/helpers/tags/datetime_field.rb +14 -6
  44. data/lib/action_view/helpers/tags/datetime_local_field.rb +11 -2
  45. data/lib/action_view/helpers/tags/grouped_collection_select.rb +3 -0
  46. data/lib/action_view/helpers/tags/month_field.rb +1 -1
  47. data/lib/action_view/helpers/tags/select.rb +3 -0
  48. data/lib/action_view/helpers/tags/select_renderer.rb +56 -0
  49. data/lib/action_view/helpers/tags/time_field.rb +1 -1
  50. data/lib/action_view/helpers/tags/time_zone_select.rb +3 -0
  51. data/lib/action_view/helpers/tags/week_field.rb +1 -1
  52. data/lib/action_view/helpers/tags/weekday_select.rb +3 -0
  53. data/lib/action_view/helpers/tags.rb +2 -0
  54. data/lib/action_view/helpers/text_helper.rb +156 -84
  55. data/lib/action_view/helpers/translation_helper.rb +3 -3
  56. data/lib/action_view/helpers/url_helper.rb +31 -78
  57. data/lib/action_view/helpers.rb +2 -0
  58. data/lib/action_view/layouts.rb +8 -8
  59. data/lib/action_view/log_subscriber.rb +57 -36
  60. data/lib/action_view/lookup_context.rb +29 -13
  61. data/lib/action_view/path_registry.rb +57 -0
  62. data/lib/action_view/path_set.rb +13 -14
  63. data/lib/action_view/railtie.rb +25 -3
  64. data/lib/action_view/record_identifier.rb +15 -8
  65. data/lib/action_view/render_parser/prism_render_parser.rb +127 -0
  66. data/lib/action_view/render_parser/ripper_render_parser.rb +341 -0
  67. data/lib/action_view/render_parser.rb +21 -169
  68. data/lib/action_view/renderer/abstract_renderer.rb +2 -2
  69. data/lib/action_view/renderer/collection_renderer.rb +10 -2
  70. data/lib/action_view/renderer/partial_renderer/collection_caching.rb +2 -1
  71. data/lib/action_view/renderer/partial_renderer.rb +2 -1
  72. data/lib/action_view/renderer/renderer.rb +34 -38
  73. data/lib/action_view/renderer/streaming_template_renderer.rb +3 -2
  74. data/lib/action_view/renderer/template_renderer.rb +3 -2
  75. data/lib/action_view/rendering.rb +26 -8
  76. data/lib/action_view/template/error.rb +14 -1
  77. data/lib/action_view/template/handlers/builder.rb +4 -4
  78. data/lib/action_view/template/handlers/erb/erubi.rb +23 -27
  79. data/lib/action_view/template/handlers/erb.rb +73 -1
  80. data/lib/action_view/template/handlers.rb +1 -1
  81. data/lib/action_view/template/html.rb +1 -1
  82. data/lib/action_view/template/raw_file.rb +1 -1
  83. data/lib/action_view/template/renderable.rb +8 -2
  84. data/lib/action_view/template/resolver.rb +9 -3
  85. data/lib/action_view/template/text.rb +1 -1
  86. data/lib/action_view/template/types.rb +25 -34
  87. data/lib/action_view/template.rb +268 -55
  88. data/lib/action_view/template_path.rb +2 -0
  89. data/lib/action_view/test_case.rb +181 -28
  90. data/lib/action_view/unbound_template.rb +17 -7
  91. data/lib/action_view/version.rb +1 -1
  92. data/lib/action_view/view_paths.rb +15 -24
  93. data/lib/action_view.rb +4 -1
  94. metadata +28 -28
  95. data/lib/action_view/ripper_ast_parser.rb +0 -198
  96. data/lib/assets/compiled/rails-ujs.js +0 -777
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a569f4f8e520c94ea5c5f0b9ab2005dd9a53e3d665bb11ecedf0f76886b6b848
4
- data.tar.gz: 4e0fc28a999734b27cf9c02900cca0dc36670e89529cbb67d8f0d72e121f5593
3
+ metadata.gz: 00d61ae3c549bc7d1a9cff55cfa4f096b50878775309401644a1d6fe23032c8c
4
+ data.tar.gz: 46dd30ccb2b17b5de7ac58dd981d616e3fbef55794c51a50865d68c10b6875ce
5
5
  SHA512:
6
- metadata.gz: 3ce2666c92327eeef024073a9780fd53c10320ef0b10c07d200fffe7ca9ec4d7634ad045a958f136a3c64432db5d2aff59b12e3ed81037118b6e67083398af64
7
- data.tar.gz: 92089fb1751e5399ddd65b5728067ff4cec2751823a320dce88418d430a22ff18c29e84fc186eb5c3514becbeb39fd372ab87f41fd44fc1543a46097642c04e1
6
+ metadata.gz: 73a1ea9695efd725f3b50f547852f1c708cc1bc63de0f2a90c6d31c79fd2161c6eb8d08feb9e019c84012d224bd30bf63d4d1535f1e874e287328935141b1f30
7
+ data.tar.gz: 818d59c9d7c22fa30695f1f1ad64d040f1187c686cf10d8f679f4f01e623bb809689acf212499cb6058314b2f4097c94b64a85d3e19aec9c708adef29ce38b39
data/CHANGELOG.md CHANGED
@@ -1,493 +1,108 @@
1
- ## Rails 7.0.8 (September 09, 2023) ##
1
+ ## Rails 7.2.0 (August 09, 2024) ##
2
2
 
3
- * Fix `form_for` missing the hidden `_method` input for models with a
4
- namespaced route.
3
+ * Fix templates with strict locals to also include `local_assigns`.
5
4
 
6
- *Hartley McGuire*
7
-
8
- * Fix `render collection: @records, cache: true` inside `jbuilder` templates
9
-
10
- The previous fix that shipped in `7.0.7` assumed template fragments are always strings,
11
- this isn't true with `jbuilder`.
5
+ Previously templates defining strict locals wouldn't receive the `local_assigns`
6
+ hash.
12
7
 
13
8
  *Jean Boussier*
14
9
 
15
- ## Rails 7.0.7.2 (August 22, 2023) ##
16
-
17
- * No changes.
18
-
19
-
20
- ## Rails 7.0.7.1 (August 22, 2023) ##
21
-
22
- * No changes.
23
-
24
-
25
- ## Rails 7.0.7 (August 09, 2023) ##
26
-
27
- * Fix `render collection: @records, cache: true` to cache fragments as bare strings
28
-
29
- Previously it would incorrectly cache them as Action View buffers.
30
-
31
- *Jean Boussier*
32
-
33
- * Don't double-encode nested `field_id` and `field_name` index values
34
-
35
- Pass `index: @options` as a default keyword argument to `field_id` and
36
- `field_name` view helper methods.
37
-
38
- *Sean Doyle*
39
-
40
-
41
- ## Rails 7.0.6 (June 29, 2023) ##
42
-
43
- * No changes.
44
-
45
-
46
- ## Rails 7.0.5.1 (June 26, 2023) ##
47
-
48
- * No changes.
49
-
50
-
51
- ## Rails 7.0.5 (May 24, 2023) ##
52
-
53
- * `FormBuilder#id` finds id set by `form_for` and `form_with`.
54
-
55
- *Matt Polito*
56
-
57
- * Allow all available locales for template lookups.
58
-
59
- *Ben Dilley*
60
-
61
- * Choices of `select` can optionally contain html attributes as the last element
62
- of the child arrays when using grouped/nested collections
63
-
64
- ```erb
65
- <%= form.select :foo, [["North America", [["United States","US"],["Canada","CA"]], { disabled: "disabled" }]] %>
66
- # => <select><optgroup label="North America" disabled="disabled"><option value="US">United States</option><option value="CA">Canada</option></optgroup></select>
67
- ```
68
-
69
- *Chris Gunther*
70
-
71
-
72
- ## Rails 7.0.4.3 (March 13, 2023) ##
73
-
74
- * Ignore certain data-* attributes in rails-ujs when element is contenteditable
75
-
76
- [CVE-2023-23913]
77
-
78
-
79
- ## Rails 7.0.4.2 (January 24, 2023) ##
80
-
81
- * No changes.
82
-
83
-
84
- ## Rails 7.0.4.1 (January 17, 2023) ##
85
-
86
- * No changes.
87
-
88
-
89
- ## Rails 7.0.4 (September 09, 2022) ##
10
+ * Add queries count to template rendering instrumentation.
90
11
 
91
- * Guard against `ActionView::Helpers::FormTagHelper#field_name` calls with nil
92
- `object_name` arguments. For example:
93
-
94
- ```erb
95
- <%= fields do |f| %>
96
- <%= f.field_name :body %>
97
- <% end %>
98
12
  ```
13
+ # Before
14
+ Completed 200 OK in 3804ms (Views: 41.0ms | ActiveRecord: 33.5ms | Allocations: 112788)
99
15
 
100
- *Sean Doyle*
101
-
102
- * Strings returned from `strip_tags` are correctly tagged `html_safe?`
103
-
104
- Because these strings contain no HTML elements and the basic entities are escaped, they are safe
105
- to be included as-is as PCDATA in HTML content. Tagging them as html-safe avoids double-escaping
106
- entities when being concatenated to a SafeBuffer during rendering.
107
-
108
- Fixes [rails/rails-html-sanitizer#124](https://github.com/rails/rails-html-sanitizer/issues/124)
109
-
110
- *Mike Dalessio*
111
-
112
- ## Rails 7.0.3.1 (July 12, 2022) ##
113
-
114
- * No changes.
115
-
116
-
117
- ## Rails 7.0.3 (May 09, 2022) ##
118
-
119
- * Ensure models passed to `form_for` attempt to call `to_model`.
120
-
121
- *Sean Doyle*
122
-
123
- ## Rails 7.0.2.4 (April 26, 2022) ##
124
-
125
- * Fix and add protections for XSS in `ActionView::Helpers` and `ERB::Util`.
126
-
127
- Escape dangerous characters in names of tags and names of attributes in the
128
- tag helpers, following the XML specification. Rename the option
129
- `:escape_attributes` to `:escape`, to simplify by applying the option to the
130
- whole tag.
131
-
132
- *Álvaro Martín Fraguas*
133
-
134
- ## Rails 7.0.2.3 (March 08, 2022) ##
135
-
136
- * No changes.
137
-
138
-
139
- ## Rails 7.0.2.2 (February 11, 2022) ##
140
-
141
- * No changes.
142
-
143
-
144
- ## Rails 7.0.2.1 (February 11, 2022) ##
145
-
146
- * No changes.
147
-
148
-
149
- ## Rails 7.0.2 (February 08, 2022) ##
150
-
151
- * Ensure `preload_link_tag` preloads JavaScript modules correctly.
152
-
153
- *Máximo Mussini*
154
-
155
- * Fix `stylesheet_link_tag` and similar helpers are being used to work in objects with
156
- a `response` method.
157
-
158
- *dark-panda*
159
-
160
-
161
- ## Rails 7.0.1 (January 06, 2022) ##
162
-
163
- * Fix `button_to` to work with a hash parameter as URL.
164
-
165
- *MingyuanQin*
166
-
167
- * Fix `link_to` with a model passed as an argument twice.
168
-
169
- *Alex Ghiculescu*
170
-
171
-
172
- ## Rails 7.0.0 (December 15, 2021) ##
173
-
174
- * Support `include_hidden:` option in calls to
175
- `ActionView::Helper::FormBuilder#file_field` with `multiple: true` to
176
- support submitting an empty collection of files.
177
-
178
- ```ruby
179
- form.file_field :attachments, multiple: true
180
- # => <input type="hidden" autocomplete="off" name="post[attachments][]" value="">
181
- <input type="file" multiple="multiple" id="post_attachments" name="post[attachments][]">
182
-
183
- form.file_field :attachments, multiple: true, include_hidden: false
184
- # => <input type="file" multiple="multiple" id="post_attachments" name="post[attachments][]">
16
+ # After
17
+ Completed 200 OK in 3804ms (Views: 41.0ms | ActiveRecord: 33.5ms (2 queries, 1 cached) | Allocations: 112788)
185
18
  ```
186
19
 
187
- *Sean Doyle*
188
-
189
- * Fix `number_with_precision(raise: true)` always raising even on valid numbers.
20
+ *fatkodima*
190
21
 
191
- *Pedro Moreira*
192
-
193
-
194
- ## Rails 7.0.0.rc3 (December 14, 2021) ##
195
-
196
- * No changes.
197
-
198
-
199
- ## Rails 7.0.0.rc2 (December 14, 2021) ##
200
-
201
- * No changes.
202
-
203
- ## Rails 7.0.0.rc1 (December 06, 2021) ##
204
-
205
- * Support `fields model: [@nested, @model]` the same way as `form_with model:
206
- [@nested, @model]`.
22
+ * Raise `ArgumentError` if `:renderable` object does not respond to `#render_in`.
207
23
 
208
24
  *Sean Doyle*
209
25
 
210
- * Infer HTTP verb `[method]` from a model or Array with model as the first
211
- argument to `button_to` when combined with a block:
26
+ * Add the `nonce: true` option for `stylesheet_link_tag` helper to support automatic nonce generation for Content Security Policy.
212
27
 
213
- ```ruby
214
- button_to(Workshop.find(1)){ "Update" }
215
- #=> <form method="post" action="/workshops/1" class="button_to">
216
- #=> <input type="hidden" name="_method" value="patch" autocomplete="off" />
217
- #=> <button type="submit">Update</button>
218
- #=> </form>
219
-
220
- button_to([ Workshop.find(1), Session.find(1) ]) { "Update" }
221
- #=> <form method="post" action="/workshops/1/sessions/1" class="button_to">
222
- #=> <input type="hidden" name="_method" value="patch" autocomplete="off" />
223
- #=> <button type="submit">Update</button>
224
- #=> </form>
225
- ```
28
+ Works the same way as `javascript_include_tag nonce: true` does.
226
29
 
227
- *Sean Doyle*
30
+ *Akhil G Krishnan*, *AJ Esler*
228
31
 
229
- * Support passing a Symbol as the first argument to `FormBuilder#button`:
230
-
231
- ```ruby
232
- form.button(:draft, value: true)
233
- # => <button name="post[draft]" value="true" type="submit">Create post</button>
234
-
235
- form.button(:draft, value: true) do
236
- content_tag(:strong, "Save as draft")
237
- end
238
- # => <button name="post[draft]" value="true" type="submit">
239
- # <strong>Save as draft</strong>
240
- # </button>
241
- ```
32
+ * Parse `ActionView::TestCase#rendered` HTML content as `Nokogiri::XML::DocumentFragment` instead of `Nokogiri::XML::Document`.
242
33
 
243
34
  *Sean Doyle*
244
35
 
245
- * Introduce the `field_name` view helper, along with the
246
- `FormBuilder#field_name` counterpart:
36
+ * Rename `ActionView::TestCase::Behavior::Content` to `ActionView::TestCase::Behavior::RenderedViewContent`.
247
37
 
248
- ```ruby
249
- form_for @post do |f|
250
- f.field_tag :tag, name: f.field_name(:tag, multiple: true)
251
- # => <input type="text" name="post[tag][]">
252
- end
253
- ```
38
+ Make `RenderedViewContent` inherit from `String`. Make private API with `:nodoc:`
254
39
 
255
40
  *Sean Doyle*
256
41
 
257
- * Execute the `ActionView::Base.field_error_proc` within the context of the
258
- `ActionView::Base` instance:
42
+ * Deprecate passing `nil` as value for the `model:` argument to the `form_with` method.
259
43
 
260
- ```ruby
261
- config.action_view.field_error_proc = proc { |html| content_tag(:div, html, class: "field_with_errors") }
262
- ```
263
-
264
- *Sean Doyle*
265
-
266
- * Add support for `button_to ..., authenticity_token: false`
267
-
268
- ```ruby
269
- button_to "Create", Post.new, authenticity_token: false
270
- # => <form class="button_to" method="post" action="/posts"><button type="submit">Create</button></form>
44
+ *Collin Jilbert*
271
45
 
272
- button_to "Create", Post.new, authenticity_token: true
273
- # => <form class="button_to" method="post" action="/posts"><button type="submit">Create</button><input type="hidden" name="form_token" value="abc123..." autocomplete="off" /></form>
274
-
275
- button_to "Create", Post.new, authenticity_token: "secret"
276
- # => <form class="button_to" method="post" action="/posts"><button type="submit">Create</button><input type="hidden" name="form_token" value="secret" autocomplete="off" /></form>
277
- ```
278
-
279
- *Sean Doyle*
280
-
281
- * Support rendering `<form>` elements _without_ `[action]` attributes by:
282
-
283
- * `form_with url: false` or `form_with ..., html: { action: false }`
284
- * `form_for ..., url: false` or `form_for ..., html: { action: false }`
285
- * `form_tag false` or `form_tag ..., action: false`
286
- * `button_to "...", false` or `button_to(false) { ... }`
46
+ * Alias `field_set_tag` helper to `fieldset_tag` to match `<fieldset>` element.
287
47
 
288
48
  *Sean Doyle*
289
49
 
290
- * Add `:day_format` option to `date_select`
291
-
292
- date_select("article", "written_on", day_format: ->(day) { day.ordinalize })
293
- # generates day options like <option value="1">1st</option>\n<option value="2">2nd</option>...
294
-
295
- *Shunichi Ikegami*
296
-
297
- * Allow `link_to` helper to infer link name from `Model#to_s` when it
298
- is used with a single argument:
299
-
300
- link_to @profile
301
- #=> <a href="/profiles/1">Eileen</a>
302
-
303
- This assumes the model class implements a `to_s` method like this:
304
-
305
- class Profile < ApplicationRecord
306
- # ...
307
- def to_s
308
- name
309
- end
310
- end
311
-
312
- Previously you had to supply a second argument even if the `Profile`
313
- model implemented a `#to_s` method that called the `name` method.
314
-
315
- link_to @profile, @profile.name
316
- #=> <a href="/profiles/1">Eileen</a>
317
-
318
- *Olivier Lacan*
319
-
320
- * Support svg unpaired tags for `tag` helper.
321
-
322
- tag.svg { tag.use('href' => "#cool-icon") }
323
- # => <svg><use href="#cool-icon"></svg>
324
-
325
- *Oleksii Vasyliev*
326
-
327
-
328
- ## Rails 7.0.0.alpha2 (September 15, 2021) ##
329
-
330
- * No changes.
331
-
50
+ * Deprecate passing content to void elements when using `tag.br` type tag builders.
332
51
 
333
- ## Rails 7.0.0.alpha1 (September 15, 2021) ##
334
-
335
- * Improves the performance of ActionView::Helpers::NumberHelper formatters by avoiding the use of
336
- exceptions as flow control.
337
-
338
- *Mike Dalessio*
339
-
340
- * `preload_link_tag` properly inserts `as` attributes for files with `image` MIME types, such as JPG or SVG.
341
-
342
- *Nate Berkopec*
343
-
344
- * Add `weekday_options_for_select` and `weekday_select` helper methods. Also adds `weekday_select` to `FormBuilder`.
345
-
346
- *Drew Bragg*, *Dana Kashubeck*, *Kasper Timm Hansen*
347
-
348
- * Add `caching?` helper that returns whether the current code path is being cached and `uncacheable!` to denote helper methods that can't participate in fragment caching.
52
+ *Hartley McGuire*
349
53
 
350
- *Ben Toews*, *John Hawthorn*, *Kasper Timm Hansen*, *Joel Hawksley*
54
+ * Fix the `number_to_human_size` view helper to correctly work with negative numbers.
351
55
 
352
- * Add `include_seconds` option for `time_field`.
56
+ *Earlopain*
353
57
 
354
- <%= form.time_field :foo, include_seconds: false %>
355
- # => <input value="16:22" type="time" />
58
+ * Automatically discard the implicit locals injected by collection rendering for template that can't accept them.
356
59
 
357
- Default includes seconds:
60
+ When rendering a collection, two implicit variables are injected, which breaks templates with strict locals.
358
61
 
359
- <%= form.time_field :foo %>
360
- # => <input value="16:22:01.440" type="time" />
62
+ Now they are only passed if the template will actually accept them.
361
63
 
362
- This allows you to take advantage of [different rendering options](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/time#time_value_format) in some browsers.
64
+ *Yasha Krasnou*, *Jean Boussier*
363
65
 
364
- *Alex Ghiculescu*
66
+ * Fix `@rails/ujs` calling `start()` an extra time when using bundlers.
365
67
 
366
- * Improve error messages when template file does not exist at absolute filepath.
68
+ *Hartley McGuire*, *Ryunosuke Sato*
367
69
 
368
- *Ted Whang*
70
+ * Fix the `capture` view helper compatibility with HAML and Slim.
369
71
 
370
- * Add `:country_code` option to `sms_to` for consistency with `phone_to`.
72
+ When a blank string was captured in HAML or Slim (and possibly other template engines)
73
+ it would instead return the entire buffer.
371
74
 
372
- *Jonathan Hefner*
75
+ *Jean Boussier*
373
76
 
374
- * OpenSSL constants are now used for Digest computations.
77
+ * Updated `@rails/ujs` files to ignore certain data-* attributes when element is contenteditable.
375
78
 
376
- *Dirkjan Bussink*
79
+ This fix was already landed in >= 7.0.4.3, < 7.1.0.
80
+ [[CVE-2023-23913](https://github.com/advisories/GHSA-xp5h-f8jf-rc8q)]
377
81
 
378
- * The `translate` helper now passes `default` values that aren't
379
- translation keys through `I18n.translate` for interpolation.
82
+ *Ryunosuke Sato*
380
83
 
381
- *Jonathan Hefner*
84
+ * Added validation for HTML tag names in the `tag` and `content_tag` helper method.
382
85
 
383
- * Adds option `extname` to `stylesheet_link_tag` to skip default
384
- `.css` extension appended to the stylesheet path.
86
+ The `tag` and `content_tag` method now checks that the provided tag name adheres to the HTML
87
+ specification. If an invalid HTML tag name is provided, the method raises an `ArgumentError`
88
+ with an appropriate error message.
385
89
 
386
- Before:
90
+ Examples:
387
91
 
388
92
  ```ruby
389
- stylesheet_link_tag "style.less"
390
- # <link href="/stylesheets/style.less.scss" rel="stylesheet">
391
- ```
392
-
393
- After:
394
-
395
- ```ruby
396
- stylesheet_link_tag "style.less", extname: false, skip_pipeline: true, rel: "stylesheet/less"
397
- # <link href="/stylesheets/style.less" rel="stylesheet/less">
398
- ```
399
-
400
- *Abhay Nikam*
401
-
402
- * Deprecate `render` locals to be assigned to instance variables.
403
-
404
- *Petrik de Heus*
405
-
406
- * Remove legacy default `media=screen` from `stylesheet_link_tag`.
407
-
408
- *André Luis Leal Cardoso Junior*
409
-
410
- * Change `ActionView::Helpers::FormBuilder#button` to transform `formmethod`
411
- attributes into `_method="$VERB"` Form Data to enable varied same-form actions:
412
-
413
- <%= form_with model: post, method: :put do %>
414
- <%= form.button "Update" %>
415
- <%= form.button "Delete", formmethod: :delete %>
416
- <% end %>
417
- <%# => <form action="posts/1">
418
- => <input type="hidden" name="_method" value="put">
419
- => <button type="submit">Update</button>
420
- => <button type="submit" formmethod="post" name="_method" value="delete">Delete</button>
421
- => </form>
422
- %>
423
-
424
- *Sean Doyle*
93
+ # Raises ArgumentError: Invalid HTML5 tag name: 12p
94
+ content_tag("12p") # Starting with a number
425
95
 
426
- * Change `ActionView::Helpers::UrlHelper#button_to` to *always* render a
427
- `<button>` element, regardless of whether or not the content is passed as
428
- the first argument or as a block.
96
+ # Raises ArgumentError: Invalid HTML5 tag name: ""
97
+ content_tag("") # Empty tag name
429
98
 
430
- <%= button_to "Delete", post_path(@post), method: :delete %>
431
- # => <form action="/posts/1"><input type="hidden" name="_method" value="delete"><button type="submit">Delete</button></form>
99
+ # Raises ArgumentError: Invalid HTML5 tag name: div/
100
+ tag("div/") # Contains a solidus
432
101
 
433
- <%= button_to post_path(@post), method: :delete do %>
434
- Delete
435
- <% end %>
436
- # => <form action="/posts/1"><input type="hidden" name="_method" value="delete"><button type="submit">Delete</button></form>
437
-
438
- *Sean Doyle*, *Dusan Orlovic*
439
-
440
- * Add `config.action_view.preload_links_header` to allow disabling of
441
- the `Link` header being added by default when using `stylesheet_link_tag`
442
- and `javascript_include_tag`.
443
-
444
- *Andrew White*
445
-
446
- * The `translate` helper now resolves `default` values when a `nil` key is
447
- specified, instead of always returning `nil`.
448
-
449
- *Jonathan Hefner*
450
-
451
- * Add `config.action_view.image_loading` to configure the default value of
452
- the `image_tag` `:loading` option.
453
-
454
- By setting `config.action_view.image_loading = "lazy"`, an application can opt in to
455
- lazy loading images sitewide, without changing view code.
456
-
457
- *Jonathan Hefner*
458
-
459
- * `ActionView::Helpers::FormBuilder#id` returns the value
460
- of the `<form>` element's `id` attribute. With a `method` argument, returns
461
- the `id` attribute for a form field with that name.
462
-
463
- <%= form_for @post do |f| %>
464
- <%# ... %>
465
-
466
- <% content_for :sticky_footer do %>
467
- <%= form.button(form: f.id) %>
468
- <% end %>
469
- <% end %>
470
-
471
- *Sean Doyle*
472
-
473
- * `ActionView::Helpers::FormBuilder#field_id` returns the value generated by
474
- the FormBuilder for the given attribute name.
475
-
476
- <%= form_for @post do |f| %>
477
- <%= f.label :title %>
478
- <%= f.text_field :title, aria: { describedby: f.field_id(:title, :error) } %>
479
- <%= tag.span("is blank", id: f.field_id(:title, :error) %>
480
- <% end %>
481
-
482
- *Sean Doyle*
483
-
484
- * Add `tag.attributes` to transform a Hash into HTML Attributes, ready to be
485
- interpolated into ERB.
486
-
487
- <input <%= tag.attributes(type: :text, aria: { label: "Search" }) %> >
488
- # => <input type="text" aria-label="Search">
489
-
490
- *Sean Doyle*
102
+ # Raises ArgumentError: Invalid HTML5 tag name: "image file"
103
+ tag("image file") # Contains a space
104
+ ```
491
105
 
106
+ *Akhil G Krishnan*
492
107
 
493
- Please check [6-1-stable](https://github.com/rails/rails/blob/6-1-stable/actionview/CHANGELOG.md) for previous changes.
108
+ Please check [7-1-stable](https://github.com/rails/rails/blob/7-1-stable/actionview/CHANGELOG.md) for previous changes.
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2004-2022 David Heinemeier Hansson
1
+ Copyright (c) David Heinemeier Hansson
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.rdoc CHANGED
@@ -5,7 +5,7 @@ view helpers that assist when building HTML forms, Atom feeds and more.
5
5
  Template formats that Action View handles are ERB (embedded Ruby, typically
6
6
  used to inline short Ruby snippets inside HTML), and XML Builder.
7
7
 
8
- You can read more about Action View in the {Action View Overview}[https://edgeguides.rubyonrails.org/action_view_overview.html] guide.
8
+ You can read more about Action View in the {Action View Overview}[https://guides.rubyonrails.org/action_view_overview.html] guide.
9
9
 
10
10
  == Download and installation
11
11