actionview 6.1.7.2 → 7.0.6

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 (80) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +268 -254
  3. data/MIT-LICENSE +1 -0
  4. data/README.rdoc +2 -2
  5. data/lib/action_view/base.rb +4 -7
  6. data/lib/action_view/buffers.rb +2 -2
  7. data/lib/action_view/cache_expiry.rb +46 -32
  8. data/lib/action_view/dependency_tracker/erb_tracker.rb +154 -0
  9. data/lib/action_view/dependency_tracker/ripper_tracker.rb +59 -0
  10. data/lib/action_view/dependency_tracker.rb +6 -147
  11. data/lib/action_view/digestor.rb +7 -4
  12. data/lib/action_view/flows.rb +4 -4
  13. data/lib/action_view/gem_version.rb +5 -5
  14. data/lib/action_view/helpers/active_model_helper.rb +2 -2
  15. data/lib/action_view/helpers/asset_tag_helper.rb +95 -39
  16. data/lib/action_view/helpers/asset_url_helper.rb +16 -16
  17. data/lib/action_view/helpers/atom_feed_helper.rb +3 -4
  18. data/lib/action_view/helpers/cache_helper.rb +52 -3
  19. data/lib/action_view/helpers/capture_helper.rb +4 -4
  20. data/lib/action_view/helpers/controller_helper.rb +2 -2
  21. data/lib/action_view/helpers/csp_helper.rb +1 -1
  22. data/lib/action_view/helpers/csrf_helper.rb +2 -2
  23. data/lib/action_view/helpers/date_helper.rb +111 -43
  24. data/lib/action_view/helpers/debug_helper.rb +3 -1
  25. data/lib/action_view/helpers/form_helper.rb +211 -85
  26. data/lib/action_view/helpers/form_options_helper.rb +70 -33
  27. data/lib/action_view/helpers/form_tag_helper.rb +150 -53
  28. data/lib/action_view/helpers/javascript_helper.rb +3 -5
  29. data/lib/action_view/helpers/number_helper.rb +17 -16
  30. data/lib/action_view/helpers/output_safety_helper.rb +4 -4
  31. data/lib/action_view/helpers/rendering_helper.rb +5 -6
  32. data/lib/action_view/helpers/sanitize_helper.rb +3 -3
  33. data/lib/action_view/helpers/tag_helper.rb +37 -8
  34. data/lib/action_view/helpers/tags/base.rb +5 -25
  35. data/lib/action_view/helpers/tags/check_box.rb +1 -1
  36. data/lib/action_view/helpers/tags/collection_select.rb +1 -1
  37. data/lib/action_view/helpers/tags/file_field.rb +16 -0
  38. data/lib/action_view/helpers/tags/select.rb +1 -1
  39. data/lib/action_view/helpers/tags/time_field.rb +10 -1
  40. data/lib/action_view/helpers/tags/weekday_select.rb +28 -0
  41. data/lib/action_view/helpers/tags.rb +3 -2
  42. data/lib/action_view/helpers/text_helper.rb +25 -14
  43. data/lib/action_view/helpers/translation_helper.rb +12 -43
  44. data/lib/action_view/helpers/url_helper.rb +194 -123
  45. data/lib/action_view/helpers.rb +25 -25
  46. data/lib/action_view/layouts.rb +7 -4
  47. data/lib/action_view/lookup_context.rb +33 -52
  48. data/lib/action_view/model_naming.rb +2 -2
  49. data/lib/action_view/path_set.rb +16 -22
  50. data/lib/action_view/railtie.rb +19 -7
  51. data/lib/action_view/record_identifier.rb +1 -1
  52. data/lib/action_view/render_parser.rb +188 -0
  53. data/lib/action_view/renderer/abstract_renderer.rb +2 -2
  54. data/lib/action_view/renderer/partial_renderer.rb +1 -35
  55. data/lib/action_view/renderer/renderer.rb +4 -4
  56. data/lib/action_view/renderer/streaming_template_renderer.rb +3 -3
  57. data/lib/action_view/renderer/template_renderer.rb +6 -2
  58. data/lib/action_view/rendering.rb +3 -3
  59. data/lib/action_view/ripper_ast_parser.rb +198 -0
  60. data/lib/action_view/routing_url_for.rb +8 -5
  61. data/lib/action_view/template/error.rb +108 -13
  62. data/lib/action_view/template/handlers/erb.rb +6 -0
  63. data/lib/action_view/template/handlers.rb +3 -3
  64. data/lib/action_view/template/html.rb +3 -3
  65. data/lib/action_view/template/inline.rb +3 -3
  66. data/lib/action_view/template/raw_file.rb +3 -3
  67. data/lib/action_view/template/resolver.rb +89 -314
  68. data/lib/action_view/template/text.rb +3 -3
  69. data/lib/action_view/template/types.rb +14 -12
  70. data/lib/action_view/template.rb +18 -2
  71. data/lib/action_view/template_details.rb +66 -0
  72. data/lib/action_view/template_path.rb +64 -0
  73. data/lib/action_view/test_case.rb +7 -3
  74. data/lib/action_view/testing/resolvers.rb +11 -12
  75. data/lib/action_view/unbound_template.rb +33 -7
  76. data/lib/action_view/version.rb +1 -1
  77. data/lib/action_view/view_paths.rb +4 -4
  78. data/lib/action_view.rb +2 -3
  79. data/lib/assets/compiled/rails-ujs.js +36 -5
  80. metadata +23 -16
data/CHANGELOG.md CHANGED
@@ -1,439 +1,453 @@
1
- ## Rails 6.1.7.2 (January 24, 2023) ##
1
+ ## Rails 7.0.6 (June 29, 2023) ##
2
2
 
3
3
  * No changes.
4
4
 
5
5
 
6
- ## Rails 6.1.7.1 (January 17, 2023) ##
6
+ ## Rails 7.0.5.1 (June 26, 2023) ##
7
7
 
8
8
  * No changes.
9
9
 
10
10
 
11
- ## Rails 6.1.7 (September 09, 2022) ##
12
-
13
- * No changes.
14
-
15
-
16
- ## Rails 6.1.6.1 (July 12, 2022) ##
17
-
18
- * No changes.
11
+ ## Rails 7.0.5 (May 24, 2023) ##
19
12
 
13
+ * `FormBuilder#id` finds id set by `form_for` and `form_with`.
20
14
 
21
- ## Rails 6.1.6 (May 09, 2022) ##
15
+ *Matt Polito*
22
16
 
23
- * No changes.
17
+ * Allow all available locales for template lookups.
24
18
 
19
+ *Ben Dilley*
25
20
 
26
- ## Rails 6.1.5.1 (April 26, 2022) ##
21
+ * Choices of `select` can optionally contain html attributes as the last element
22
+ of the child arrays when using grouped/nested collections
27
23
 
28
- * Fix and add protections for XSS in `ActionView::Helpers` and `ERB::Util`.
29
-
30
- Escape dangerous characters in names of tags and names of attributes in the
31
- tag helpers, following the XML specification. Rename the option
32
- `:escape_attributes` to `:escape`, to simplify by applying the option to the
33
- whole tag.
34
-
35
- *Álvaro Martín Fraguas*
36
-
37
- ## Rails 6.1.5 (March 09, 2022) ##
38
-
39
- * `preload_link_tag` properly inserts `as` attributes for files with `image` MIME
40
- types, such as JPG or SVG.
41
-
42
- *Nate Berkopec*
43
-
44
- * Add `autocomplete="off"` to all generated hidden fields.
45
-
46
- Fixes #42610.
47
-
48
- *Ryan Baumann*
49
-
50
- * Fix `current_page?` when URL has trailing slash.
24
+ ```erb
25
+ <%= form.select :foo, [["North America", [["United States","US"],["Canada","CA"]], { disabled: "disabled" }]] %>
26
+ # => <select><optgroup label="North America" disabled="disabled"><option value="US">United States</option><option value="CA">Canada</option></optgroup></select>
27
+ ```
51
28
 
52
- This fixes the `current_page?` helper when the given URL has a trailing slash,
53
- and is an absolute URL or also has query params.
29
+ *Chris Gunther*
54
30
 
55
- Fixes #33956.
56
31
 
57
- *Jonathan Hefner*
32
+ ## Rails 7.0.4.3 (March 13, 2023) ##
58
33
 
34
+ * Ignore certain data-* attributes in rails-ujs when element is contenteditable
59
35
 
60
- ## Rails 6.1.4.7 (March 08, 2022) ##
36
+ [CVE-2023-23913]
61
37
 
62
- * No changes.
63
38
 
64
-
65
- ## Rails 6.1.4.6 (February 11, 2022) ##
39
+ ## Rails 7.0.4.2 (January 24, 2023) ##
66
40
 
67
41
  * No changes.
68
42
 
69
43
 
70
- ## Rails 6.1.4.5 (February 11, 2022) ##
44
+ ## Rails 7.0.4.1 (January 17, 2023) ##
71
45
 
72
46
  * No changes.
73
47
 
74
48
 
75
- ## Rails 6.1.4.4 (December 15, 2021) ##
76
-
77
- * No changes.
49
+ ## Rails 7.0.4 (September 09, 2022) ##
78
50
 
51
+ * Guard against `ActionView::Helpers::FormTagHelper#field_name` calls with nil
52
+ `object_name` arguments. For example:
79
53
 
80
- ## Rails 6.1.4.3 (December 14, 2021) ##
54
+ ```erb
55
+ <%= fields do |f| %>
56
+ <%= f.field_name :body %>
57
+ <% end %>
58
+ ```
81
59
 
82
- * No changes.
60
+ *Sean Doyle*
83
61
 
62
+ * Strings returned from `strip_tags` are correctly tagged `html_safe?`
84
63
 
85
- ## Rails 6.1.4.2 (December 14, 2021) ##
64
+ Because these strings contain no HTML elements and the basic entities are escaped, they are safe
65
+ to be included as-is as PCDATA in HTML content. Tagging them as html-safe avoids double-escaping
66
+ entities when being concatenated to a SafeBuffer during rendering.
86
67
 
87
- * No changes.
68
+ Fixes [rails/rails-html-sanitizer#124](https://github.com/rails/rails-html-sanitizer/issues/124)
88
69
 
70
+ *Mike Dalessio*
89
71
 
90
- ## Rails 6.1.4.1 (August 19, 2021) ##
72
+ ## Rails 7.0.3.1 (July 12, 2022) ##
91
73
 
92
74
  * No changes.
93
75
 
94
76
 
95
- ## Rails 6.1.4 (June 24, 2021) ##
96
-
97
- * The `translate` helper now passes `default` values that aren't
98
- translation keys through `I18n.translate` for interpolation.
77
+ ## Rails 7.0.3 (May 09, 2022) ##
99
78
 
100
- *Jonathan Hefner*
79
+ * Ensure models passed to `form_for` attempt to call `to_model`.
101
80
 
102
- * Don't attach UJS form submission handlers to Turbo forms.
81
+ *Sean Doyle*
103
82
 
104
- *David Heinemeier Hansson*
83
+ ## Rails 7.0.2.4 (April 26, 2022) ##
105
84
 
106
- * Allow both `current_page?(url_hash)` and `current_page?(**url_hash)` on Ruby 2.7.
85
+ * Fix and add protections for XSS in `ActionView::Helpers` and `ERB::Util`.
107
86
 
108
- *Ryuta Kamizono*
87
+ Escape dangerous characters in names of tags and names of attributes in the
88
+ tag helpers, following the XML specification. Rename the option
89
+ `:escape_attributes` to `:escape`, to simplify by applying the option to the
90
+ whole tag.
109
91
 
92
+ *Álvaro Martín Fraguas*
110
93
 
111
- ## Rails 6.1.3.2 (May 05, 2021) ##
94
+ ## Rails 7.0.2.3 (March 08, 2022) ##
112
95
 
113
96
  * No changes.
114
97
 
115
98
 
116
- ## Rails 6.1.3.1 (March 26, 2021) ##
99
+ ## Rails 7.0.2.2 (February 11, 2022) ##
117
100
 
118
101
  * No changes.
119
102
 
120
103
 
121
- ## Rails 6.1.3 (February 17, 2021) ##
104
+ ## Rails 7.0.2.1 (February 11, 2022) ##
122
105
 
123
106
  * No changes.
124
107
 
125
108
 
126
- ## Rails 6.1.2.1 (February 10, 2021) ##
127
-
128
- * No changes.
109
+ ## Rails 7.0.2 (February 08, 2022) ##
129
110
 
111
+ * Ensure `preload_link_tag` preloads JavaScript modules correctly.
130
112
 
131
- ## Rails 6.1.2 (February 09, 2021) ##
113
+ *Máximo Mussini*
132
114
 
133
- * No changes.
115
+ * Fix `stylesheet_link_tag` and similar helpers are being used to work in objects with
116
+ a `response` method.
134
117
 
118
+ *dark-panda*
135
119
 
136
- ## Rails 6.1.1 (January 07, 2021) ##
137
120
 
138
- * Fix lazy translation in partial with block.
121
+ ## Rails 7.0.1 (January 06, 2022) ##
139
122
 
140
- *Marek Kasztelnik*
123
+ * Fix `button_to` to work with a hash parameter as URL.
141
124
 
142
- * Avoid extra `SELECT COUNT` queries when rendering Active Record collections.
125
+ *MingyuanQin*
143
126
 
144
- *aar0nr*
127
+ * Fix `link_to` with a model passed as an argument twice.
145
128
 
146
- * Link preloading keep integrity hashes in the header.
129
+ *Alex Ghiculescu*
147
130
 
148
- *Étienne Barrié*
149
-
150
- * Add `config.action_view.preload_links_header` to allow disabling of
151
- the `Link` header being added by default when using `stylesheet_link_tag`
152
- and `javascript_include_tag`.
153
131
 
154
- *Andrew White*
132
+ ## Rails 7.0.0 (December 15, 2021) ##
155
133
 
156
- * The `translate` helper now resolves `default` values when a `nil` key is
157
- specified, instead of always returning `nil`.
134
+ * Support `include_hidden:` option in calls to
135
+ `ActionView::Helper::FormBuilder#file_field` with `multiple: true` to
136
+ support submitting an empty collection of files.
158
137
 
159
- *Jonathan Hefner*
138
+ ```ruby
139
+ form.file_field :attachments, multiple: true
140
+ # => <input type="hidden" autocomplete="off" name="post[attachments][]" value="">
141
+ <input type="file" multiple="multiple" id="post_attachments" name="post[attachments][]">
160
142
 
143
+ form.file_field :attachments, multiple: true, include_hidden: false
144
+ # => <input type="file" multiple="multiple" id="post_attachments" name="post[attachments][]">
145
+ ```
161
146
 
162
- ## Rails 6.1.0 (December 09, 2020) ##
147
+ *Sean Doyle*
163
148
 
164
- * SanitizeHelper.sanitized_allowed_attributes and SanitizeHelper.sanitized_allowed_tags
165
- call safe_list_sanitizer's class method
149
+ * Fix `number_with_precision(raise: true)` always raising even on valid numbers.
166
150
 
167
- Fixes #39586
151
+ *Pedro Moreira*
168
152
 
169
- *Taufiq Muhammadi*
170
153
 
171
- * Change form_with to generate non-remote forms by default.
154
+ ## Rails 7.0.0.rc3 (December 14, 2021) ##
172
155
 
173
- `form_with` would generate a remote form by default. This would confuse
174
- users because they were forced to handle remote requests.
156
+ * No changes.
175
157
 
176
- All new 6.1 applications will generate non-remote forms by default.
177
- When upgrading a 6.0 application you can enable remote forms by default by
178
- setting `config.action_view.form_with_generates_remote_forms` to `true`.
179
158
 
180
- *Petrik de Heus*
159
+ ## Rails 7.0.0.rc2 (December 14, 2021) ##
181
160
 
182
- * Yield translated strings to calls of `ActionView::FormBuilder#button`
183
- when a block is given.
161
+ * No changes.
184
162
 
185
- *Sean Doyle*
163
+ ## Rails 7.0.0.rc1 (December 06, 2021) ##
186
164
 
187
- * Alias `ActionView::Helpers::Tags::Label::LabelBuilder#translation` to
188
- `#to_s` so that `form.label` calls can yield that value to their blocks.
165
+ * Support `fields model: [@nested, @model]` the same way as `form_with model:
166
+ [@nested, @model]`.
189
167
 
190
168
  *Sean Doyle*
191
169
 
192
- * Rename the new `TagHelper#class_names` method to `TagHelper#token_list`,
193
- and make the original available as an alias.
194
-
195
- token_list("foo", "foo bar")
196
- # => "foo bar"
197
-
198
- *Sean Doyle*
170
+ * Infer HTTP verb `[method]` from a model or Array with model as the first
171
+ argument to `button_to` when combined with a block:
199
172
 
200
- * ARIA Array and Hash attributes are treated as space separated `DOMTokenList`
201
- values. This is useful when declaring lists of label text identifiers in
202
- `aria-labelledby` or `aria-describedby`.
203
-
204
- tag.input type: 'checkbox', name: 'published', aria: {
205
- invalid: @post.errors[:published].any?,
206
- labelledby: ['published_context', 'published_label'],
207
- describedby: { published_errors: @post.errors[:published].any? }
208
- }
209
- #=> <input
210
- type="checkbox" name="published" aria-invalid="true"
211
- aria-labelledby="published_context published_label"
212
- aria-describedby="published_errors"
213
- >
173
+ ```ruby
174
+ button_to(Workshop.find(1)){ "Update" }
175
+ #=> <form method="post" action="/workshops/1" class="button_to">
176
+ #=> <input type="hidden" name="_method" value="patch" autocomplete="off" />
177
+ #=> <button type="submit">Update</button>
178
+ #=> </form>
179
+
180
+ button_to([ Workshop.find(1), Session.find(1) ]) { "Update" }
181
+ #=> <form method="post" action="/workshops/1/sessions/1" class="button_to">
182
+ #=> <input type="hidden" name="_method" value="patch" autocomplete="off" />
183
+ #=> <button type="submit">Update</button>
184
+ #=> </form>
185
+ ```
214
186
 
215
187
  *Sean Doyle*
216
188
 
217
- * Remove deprecated `escape_whitelist` from `ActionView::Template::Handlers::ERB`.
218
-
219
- *Rafael Mendonça França*
189
+ * Support passing a Symbol as the first argument to `FormBuilder#button`:
220
190
 
221
- * Remove deprecated `find_all_anywhere` from `ActionView::Resolver`.
222
-
223
- *Rafael Mendonça França*
191
+ ```ruby
192
+ form.button(:draft, value: true)
193
+ # => <button name="post[draft]" value="true" type="submit">Create post</button>
194
+
195
+ form.button(:draft, value: true) do
196
+ content_tag(:strong, "Save as draft")
197
+ end
198
+ # => <button name="post[draft]" value="true" type="submit">
199
+ # <strong>Save as draft</strong>
200
+ # </button>
201
+ ```
224
202
 
225
- * Remove deprecated `formats` from `ActionView::Template::HTML`.
203
+ *Sean Doyle*
226
204
 
227
- *Rafael Mendonça França*
205
+ * Introduce the `field_name` view helper, along with the
206
+ `FormBuilder#field_name` counterpart:
228
207
 
229
- * Remove deprecated `formats` from `ActionView::Template::RawFile`.
208
+ ```ruby
209
+ form_for @post do |f|
210
+ f.field_tag :tag, name: f.field_name(:tag, multiple: true)
211
+ # => <input type="text" name="post[tag][]">
212
+ end
213
+ ```
230
214
 
231
- *Rafael Mendonça França*
215
+ *Sean Doyle*
232
216
 
233
- * Remove deprecated `formats` from `ActionView::Template::Text`.
217
+ * Execute the `ActionView::Base.field_error_proc` within the context of the
218
+ `ActionView::Base` instance:
234
219
 
235
- *Rafael Mendonça França*
220
+ ```ruby
221
+ config.action_view.field_error_proc = proc { |html| content_tag(:div, html, class: "field_with_errors") }
222
+ ```
236
223
 
237
- * Remove deprecated `find_file` from `ActionView::PathSet`.
224
+ *Sean Doyle*
238
225
 
239
- *Rafael Mendonça França*
226
+ * Add support for `button_to ..., authenticity_token: false`
240
227
 
241
- * Remove deprecated `rendered_format` from `ActionView::LookupContext`.
228
+ ```ruby
229
+ button_to "Create", Post.new, authenticity_token: false
230
+ # => <form class="button_to" method="post" action="/posts"><button type="submit">Create</button></form>
242
231
 
243
- *Rafael Mendonça França*
232
+ button_to "Create", Post.new, authenticity_token: true
233
+ # => <form class="button_to" method="post" action="/posts"><button type="submit">Create</button><input type="hidden" name="form_token" value="abc123..." autocomplete="off" /></form>
244
234
 
245
- * Remove deprecated `find_file` from `ActionView::ViewPaths`.
235
+ button_to "Create", Post.new, authenticity_token: "secret"
236
+ # => <form class="button_to" method="post" action="/posts"><button type="submit">Create</button><input type="hidden" name="form_token" value="secret" autocomplete="off" /></form>
237
+ ```
246
238
 
247
- *Rafael Mendonça França*
239
+ *Sean Doyle*
248
240
 
249
- * Require that `ActionView::Base` subclasses implement `#compiled_method_container`.
241
+ * Support rendering `<form>` elements _without_ `[action]` attributes by:
250
242
 
251
- *Rafael Mendonça França*
243
+ * `form_with url: false` or `form_with ..., html: { action: false }`
244
+ * `form_for ..., url: false` or `form_for ..., html: { action: false }`
245
+ * `form_tag false` or `form_tag ..., action: false`
246
+ * `button_to "...", false` or `button_to(false) { ... }`
252
247
 
253
- * Remove deprecated support to pass an object that is not a `ActionView::LookupContext` as the first argument
254
- in `ActionView::Base#initialize`.
248
+ *Sean Doyle*
255
249
 
256
- *Rafael Mendonça França*
250
+ * Add `:day_format` option to `date_select`
257
251
 
258
- * Remove deprecated `format` argument `ActionView::Base#initialize`.
252
+ date_select("article", "written_on", day_format: ->(day) { day.ordinalize })
253
+ # generates day options like <option value="1">1st</option>\n<option value="2">2nd</option>...
259
254
 
260
- *Rafael Mendonça França*
255
+ *Shunichi Ikegami*
261
256
 
262
- * Remove deprecated `ActionView::Template#refresh`.
257
+ * Allow `link_to` helper to infer link name from `Model#to_s` when it
258
+ is used with a single argument:
263
259
 
264
- *Rafael Mendonça França*
260
+ link_to @profile
261
+ #=> <a href="/profiles/1">Eileen</a>
265
262
 
266
- * Remove deprecated `ActionView::Template#original_encoding`.
263
+ This assumes the model class implements a `to_s` method like this:
267
264
 
268
- *Rafael Mendonça França*
265
+ class Profile < ApplicationRecord
266
+ # ...
267
+ def to_s
268
+ name
269
+ end
270
+ end
269
271
 
270
- * Remove deprecated `ActionView::Template#variants`.
272
+ Previously you had to supply a second argument even if the `Profile`
273
+ model implemented a `#to_s` method that called the `name` method.
271
274
 
272
- *Rafael Mendonça França*
275
+ link_to @profile, @profile.name
276
+ #=> <a href="/profiles/1">Eileen</a>
273
277
 
274
- * Remove deprecated `ActionView::Template#formats`.
278
+ *Olivier Lacan*
275
279
 
276
- *Rafael Mendonça França*
280
+ * Support svg unpaired tags for `tag` helper.
277
281
 
278
- * Remove deprecated `ActionView::Template#virtual_path=`.
282
+ tag.svg { tag.use('href' => "#cool-icon") }
283
+ # => <svg><use href="#cool-icon"></svg>
279
284
 
280
- *Rafael Mendonça França*
285
+ *Oleksii Vasyliev*
281
286
 
282
- * Remove deprecated `ActionView::Template#updated_at`.
283
287
 
284
- *Rafael Mendonça França*
288
+ ## Rails 7.0.0.alpha2 (September 15, 2021) ##
285
289
 
286
- * Remove deprecated `updated_at` argument required on `ActionView::Template#initialize`.
290
+ * No changes.
287
291
 
288
- *Rafael Mendonça França*
289
292
 
290
- * Make `locals` argument required on `ActionView::Template#initialize`.
293
+ ## Rails 7.0.0.alpha1 (September 15, 2021) ##
291
294
 
292
- *Rafael Mendonça França*
295
+ * Improves the performance of ActionView::Helpers::NumberHelper formatters by avoiding the use of
296
+ exceptions as flow control.
293
297
 
294
- * Remove deprecated `ActionView::Template.finalize_compiled_template_methods`.
298
+ *Mike Dalessio*
295
299
 
296
- *Rafael Mendonça França*
300
+ * `preload_link_tag` properly inserts `as` attributes for files with `image` MIME types, such as JPG or SVG.
297
301
 
298
- * Remove deprecated `config.action_view.finalize_compiled_template_methods`
302
+ *Nate Berkopec*
299
303
 
300
- *Rafael Mendonça França*
304
+ * Add `weekday_options_for_select` and `weekday_select` helper methods. Also adds `weekday_select` to `FormBuilder`.
301
305
 
302
- * Remove deprecated support to calling `ActionView::ViewPaths#with_fallback` with a block.
306
+ *Drew Bragg*, *Dana Kashubeck*, *Kasper Timm Hansen*
303
307
 
304
- *Rafael Mendonça França*
308
+ * 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.
305
309
 
306
- * Remove deprecated support to passing absolute paths to `render template:`.
310
+ *Ben Toews*, *John Hawthorn*, *Kasper Timm Hansen*, *Joel Hawksley*
307
311
 
308
- *Rafael Mendonça França*
312
+ * Add `include_seconds` option for `time_field`.
309
313
 
310
- * Remove deprecated support to passing relative paths to `render file:`.
314
+ <%= form.time_field :foo, include_seconds: false %>
315
+ # => <input value="16:22" type="time" />
311
316
 
312
- *Rafael Mendonça França*
317
+ Default includes seconds:
313
318
 
314
- * Remove support to template handlers that don't accept two arguments.
319
+ <%= form.time_field :foo %>
320
+ # => <input value="16:22:01.440" type="time" />
315
321
 
316
- *Rafael Mendonça França*
322
+ 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.
317
323
 
318
- * Remove deprecated pattern argument in `ActionView::Template::PathResolver`.
324
+ *Alex Ghiculescu*
319
325
 
320
- *Rafael Mendonça França*
326
+ * Improve error messages when template file does not exist at absolute filepath.
321
327
 
322
- * Remove deprecated support to call private methods from object in some view helpers.
328
+ *Ted Whang*
323
329
 
324
- *Rafael Mendonça França*
330
+ * Add `:country_code` option to `sms_to` for consistency with `phone_to`.
325
331
 
326
- * `ActionView::Helpers::TranslationHelper#translate` accepts a block, yielding
327
- the translated text and the fully resolved translation key:
332
+ *Jonathan Hefner*
328
333
 
329
- <%= translate(".relative_key") do |translation, resolved_key| %>
330
- <span title="<%= resolved_key %>"><%= translation %></span>
331
- <% end %>
334
+ * OpenSSL constants are now used for Digest computations.
332
335
 
333
- *Sean Doyle*
336
+ *Dirkjan Bussink*
334
337
 
335
- * Ensure cache fragment digests include all relevant template dependencies when
336
- fragments are contained in a block passed to the render helper. Remove the
337
- virtual_path keyword arguments found in CacheHelper as they no longer possess
338
- any function following 1581cab.
338
+ * The `translate` helper now passes `default` values that aren't
339
+ translation keys through `I18n.translate` for interpolation.
339
340
 
340
- Fixes #38984.
341
+ *Jonathan Hefner*
341
342
 
342
- *Aaron Lipman*
343
+ * Adds option `extname` to `stylesheet_link_tag` to skip default
344
+ `.css` extension appended to the stylesheet path.
343
345
 
344
- * Deprecate `config.action_view.raise_on_missing_translations` in favor of
345
- `config.i18n.raise_on_missing_translations`.
346
+ Before:
346
347
 
347
- New generalized configuration option now determines whether an error should be raised
348
- for missing translations in controllers and views.
348
+ ```ruby
349
+ stylesheet_link_tag "style.less"
350
+ # <link href="/stylesheets/style.less.scss" rel="stylesheet">
351
+ ```
349
352
 
350
- *fatkodima*
353
+ After:
351
354
 
352
- * Instrument layout rendering in `TemplateRenderer#render_with_layout` as `render_layout.action_view`,
353
- and include (when necessary) the layout's virtual path in notification payloads for collection and partial renders.
355
+ ```ruby
356
+ stylesheet_link_tag "style.less", extname: false, skip_pipeline: true, rel: "stylesheet/less"
357
+ # <link href="/stylesheets/style.less" rel="stylesheet/less">
358
+ ```
354
359
 
355
- *Zach Kemp*
360
+ *Abhay Nikam*
356
361
 
357
- * `ActionView::Base.annotate_rendered_view_with_filenames` annotates HTML output with template file names.
362
+ * Deprecate `render` locals to be assigned to instance variables.
358
363
 
359
- *Joel Hawksley*, *Aaron Patterson*
364
+ *Petrik de Heus*
360
365
 
361
- * `ActionView::Helpers::TranslationHelper#translate` returns nil when
362
- passed `default: nil` without a translation matching `I18n#translate`.
366
+ * Remove legacy default `media=screen` from `stylesheet_link_tag`.
363
367
 
364
- *Stefan Wrobel*
368
+ *André Luis Leal Cardoso Junior*
365
369
 
366
- * `OptimizedFileSystemResolver` prefers template details in order of locale,
367
- formats, variants, handlers.
370
+ * Change `ActionView::Helpers::FormBuilder#button` to transform `formmethod`
371
+ attributes into `_method="$VERB"` Form Data to enable varied same-form actions:
368
372
 
369
- *Iago Pimenta*
373
+ <%= form_with model: post, method: :put do %>
374
+ <%= form.button "Update" %>
375
+ <%= form.button "Delete", formmethod: :delete %>
376
+ <% end %>
377
+ <%# => <form action="posts/1">
378
+ => <input type="hidden" name="_method" value="put">
379
+ => <button type="submit">Update</button>
380
+ => <button type="submit" formmethod="post" name="_method" value="delete">Delete</button>
381
+ => </form>
382
+ %>
370
383
 
371
- * Added `class_names` helper to create a CSS class value with conditional classes.
384
+ *Sean Doyle*
372
385
 
373
- *Joel Hawksley*, *Aaron Patterson*
386
+ * Change `ActionView::Helpers::UrlHelper#button_to` to *always* render a
387
+ `<button>` element, regardless of whether or not the content is passed as
388
+ the first argument or as a block.
374
389
 
375
- * Add support for conditional values to TagBuilder.
390
+ <%= button_to "Delete", post_path(@post), method: :delete %>
391
+ # => <form action="/posts/1"><input type="hidden" name="_method" value="delete"><button type="submit">Delete</button></form>
376
392
 
377
- *Joel Hawksley*
393
+ <%= button_to post_path(@post), method: :delete do %>
394
+ Delete
395
+ <% end %>
396
+ # => <form action="/posts/1"><input type="hidden" name="_method" value="delete"><button type="submit">Delete</button></form>
378
397
 
379
- * `ActionView::Helpers::FormOptionsHelper#select` should mark option for `nil` as selected.
398
+ *Sean Doyle*, *Dusan Orlovic*
380
399
 
381
- ```ruby
382
- @post = Post.new
383
- @post.category = nil
384
-
385
- # Before
386
- select("post", "category", none: nil, programming: 1, economics: 2)
387
- # =>
388
- # <select name="post[category]" id="post_category">
389
- # <option value="">none</option>
390
- # <option value="1">programming</option>
391
- # <option value="2">economics</option>
392
- # </select>
393
-
394
- # After
395
- select("post", "category", none: nil, programming: 1, economics: 2)
396
- # =>
397
- # <select name="post[category]" id="post_category">
398
- # <option selected="selected" value="">none</option>
399
- # <option value="1">programming</option>
400
- # <option value="2">economics</option>
401
- # </select>
402
- ```
400
+ * Add `config.action_view.preload_links_header` to allow disabling of
401
+ the `Link` header being added by default when using `stylesheet_link_tag`
402
+ and `javascript_include_tag`.
403
403
 
404
- *bogdanvlviv*
404
+ *Andrew White*
405
405
 
406
- * Log lines for partial renders and started template renders are now
407
- emitted at the `DEBUG` level instead of `INFO`.
406
+ * The `translate` helper now resolves `default` values when a `nil` key is
407
+ specified, instead of always returning `nil`.
408
408
 
409
- Completed template renders are still logged at the `INFO` level.
409
+ *Jonathan Hefner*
410
410
 
411
- *DHH*
411
+ * Add `config.action_view.image_loading` to configure the default value of
412
+ the `image_tag` `:loading` option.
412
413
 
413
- * ActionView::Helpers::SanitizeHelper: support rails-html-sanitizer 1.1.0.
414
+ By setting `config.action_view.image_loading = "lazy"`, an application can opt in to
415
+ lazy loading images sitewide, without changing view code.
414
416
 
415
- *Juanito Fatas*
417
+ *Jonathan Hefner*
416
418
 
417
- * Added `phone_to` helper method to create a link from mobile numbers.
419
+ * `ActionView::Helpers::FormBuilder#id` returns the value
420
+ of the `<form>` element's `id` attribute. With a `method` argument, returns
421
+ the `id` attribute for a form field with that name.
418
422
 
419
- *Pietro Moro*
423
+ <%= form_for @post do |f| %>
424
+ <%# ... %>
420
425
 
421
- * annotated_source_code returns an empty array so TemplateErrors without a
422
- template in the backtrace are surfaced properly by DebugExceptions.
426
+ <% content_for :sticky_footer do %>
427
+ <%= form.button(form: f.id) %>
428
+ <% end %>
429
+ <% end %>
423
430
 
424
- *Guilherme Mansur*, *Kasper Timm Hansen*
431
+ *Sean Doyle*
425
432
 
426
- * Add autoload for SyntaxErrorInTemplate so syntax errors are correctly raised by DebugExceptions.
433
+ * `ActionView::Helpers::FormBuilder#field_id` returns the value generated by
434
+ the FormBuilder for the given attribute name.
427
435
 
428
- *Guilherme Mansur*, *Gannon McGibbon*
436
+ <%= form_for @post do |f| %>
437
+ <%= f.label :title %>
438
+ <%= f.text_field :title, aria: { describedby: f.field_id(:title, :error) } %>
439
+ <%= tag.span("is blank", id: f.field_id(:title, :error) %>
440
+ <% end %>
429
441
 
430
- * `RenderingHelper` supports rendering objects that `respond_to?` `:render_in`.
442
+ *Sean Doyle*
431
443
 
432
- *Joel Hawksley*, *Natasha Umer*, *Aaron Patterson*, *Shawn Allen*, *Emily Plummer*, *Diana Mounter*, *John Hawthorn*, *Nathan Herald*, *Zaid Zawaideh*, *Zach Ahn*
444
+ * Add `tag.attributes` to transform a Hash into HTML Attributes, ready to be
445
+ interpolated into ERB.
433
446
 
434
- * Fix `select_tag` so that it doesn't change `options` when `include_blank` is present.
447
+ <input <%= tag.attributes(type: :text, aria: { label: "Search" }) %> >
448
+ # => <input type="text" aria-label="Search">
435
449
 
436
- *Younes SERRAJ*
450
+ *Sean Doyle*
437
451
 
438
452
 
439
- Please check [6-0-stable](https://github.com/rails/rails/blob/6-0-stable/actionview/CHANGELOG.md) for previous changes.
453
+ Please check [6-1-stable](https://github.com/rails/rails/blob/6-1-stable/actionview/CHANGELOG.md) for previous changes.