actionview 6.1.7.9 → 7.0.8.7

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