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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +299 -247
- data/MIT-LICENSE +1 -0
- data/README.rdoc +2 -2
- data/lib/action_view/base.rb +4 -7
- data/lib/action_view/buffers.rb +2 -2
- data/lib/action_view/cache_expiry.rb +46 -32
- data/lib/action_view/dependency_tracker/erb_tracker.rb +154 -0
- data/lib/action_view/dependency_tracker/ripper_tracker.rb +59 -0
- data/lib/action_view/dependency_tracker.rb +6 -147
- data/lib/action_view/digestor.rb +7 -4
- data/lib/action_view/flows.rb +4 -4
- data/lib/action_view/gem_version.rb +5 -5
- data/lib/action_view/helpers/active_model_helper.rb +2 -2
- data/lib/action_view/helpers/asset_tag_helper.rb +95 -39
- data/lib/action_view/helpers/asset_url_helper.rb +16 -16
- data/lib/action_view/helpers/atom_feed_helper.rb +3 -4
- data/lib/action_view/helpers/cache_helper.rb +52 -3
- data/lib/action_view/helpers/capture_helper.rb +4 -4
- data/lib/action_view/helpers/controller_helper.rb +2 -2
- data/lib/action_view/helpers/csp_helper.rb +1 -1
- data/lib/action_view/helpers/csrf_helper.rb +2 -2
- data/lib/action_view/helpers/date_helper.rb +111 -43
- data/lib/action_view/helpers/debug_helper.rb +3 -1
- data/lib/action_view/helpers/form_helper.rb +211 -84
- data/lib/action_view/helpers/form_options_helper.rb +70 -33
- data/lib/action_view/helpers/form_tag_helper.rb +150 -53
- data/lib/action_view/helpers/javascript_helper.rb +3 -5
- data/lib/action_view/helpers/number_helper.rb +17 -16
- data/lib/action_view/helpers/output_safety_helper.rb +4 -4
- data/lib/action_view/helpers/rendering_helper.rb +5 -6
- data/lib/action_view/helpers/sanitize_helper.rb +3 -3
- data/lib/action_view/helpers/tag_helper.rb +37 -8
- data/lib/action_view/helpers/tags/base.rb +5 -25
- data/lib/action_view/helpers/tags/check_box.rb +1 -1
- data/lib/action_view/helpers/tags/collection_select.rb +1 -1
- data/lib/action_view/helpers/tags/file_field.rb +16 -0
- data/lib/action_view/helpers/tags/select.rb +1 -1
- data/lib/action_view/helpers/tags/time_field.rb +10 -1
- data/lib/action_view/helpers/tags/weekday_select.rb +28 -0
- data/lib/action_view/helpers/tags.rb +3 -2
- data/lib/action_view/helpers/text_helper.rb +25 -14
- data/lib/action_view/helpers/translation_helper.rb +12 -43
- data/lib/action_view/helpers/url_helper.rb +194 -123
- data/lib/action_view/helpers.rb +25 -25
- data/lib/action_view/layouts.rb +7 -4
- data/lib/action_view/lookup_context.rb +33 -52
- data/lib/action_view/model_naming.rb +2 -2
- data/lib/action_view/path_set.rb +16 -22
- data/lib/action_view/railtie.rb +19 -7
- data/lib/action_view/record_identifier.rb +1 -1
- data/lib/action_view/render_parser.rb +188 -0
- data/lib/action_view/renderer/abstract_renderer.rb +2 -2
- data/lib/action_view/renderer/partial_renderer/collection_caching.rb +20 -3
- data/lib/action_view/renderer/partial_renderer.rb +1 -35
- data/lib/action_view/renderer/renderer.rb +4 -4
- data/lib/action_view/renderer/streaming_template_renderer.rb +3 -3
- data/lib/action_view/renderer/template_renderer.rb +6 -2
- data/lib/action_view/rendering.rb +3 -3
- data/lib/action_view/ripper_ast_parser.rb +198 -0
- data/lib/action_view/routing_url_for.rb +8 -5
- data/lib/action_view/template/error.rb +108 -13
- data/lib/action_view/template/handlers/erb.rb +6 -0
- data/lib/action_view/template/handlers.rb +3 -3
- data/lib/action_view/template/html.rb +3 -3
- data/lib/action_view/template/inline.rb +3 -3
- data/lib/action_view/template/raw_file.rb +3 -3
- data/lib/action_view/template/resolver.rb +89 -314
- data/lib/action_view/template/text.rb +3 -3
- data/lib/action_view/template/types.rb +14 -12
- data/lib/action_view/template.rb +18 -2
- data/lib/action_view/template_details.rb +66 -0
- data/lib/action_view/template_path.rb +64 -0
- data/lib/action_view/test_case.rb +7 -3
- data/lib/action_view/testing/resolvers.rb +11 -12
- data/lib/action_view/unbound_template.rb +33 -7
- data/lib/action_view/version.rb +1 -1
- data/lib/action_view/view_paths.rb +4 -4
- data/lib/action_view.rb +2 -3
- metadata +20 -13
data/CHANGELOG.md
CHANGED
@@ -1,476 +1,528 @@
|
|
1
|
-
## Rails
|
1
|
+
## Rails 7.0.8.7 (December 10, 2024) ##
|
2
2
|
|
3
3
|
* No changes.
|
4
4
|
|
5
5
|
|
6
|
-
## Rails
|
6
|
+
## Rails 7.0.8.6 (October 23, 2024) ##
|
7
7
|
|
8
8
|
* No changes.
|
9
9
|
|
10
10
|
|
11
|
-
## Rails
|
11
|
+
## Rails 7.0.8.5 (October 15, 2024) ##
|
12
12
|
|
13
13
|
* No changes.
|
14
14
|
|
15
15
|
|
16
|
-
## Rails
|
16
|
+
## Rails 7.0.8.4 (June 04, 2024) ##
|
17
17
|
|
18
18
|
* No changes.
|
19
19
|
|
20
20
|
|
21
|
-
## Rails
|
21
|
+
## Rails 7.0.8.3 (May 17, 2024) ##
|
22
22
|
|
23
23
|
* No changes.
|
24
24
|
|
25
25
|
|
26
|
-
## Rails
|
26
|
+
## Rails 7.0.8.2 (May 16, 2024) ##
|
27
27
|
|
28
28
|
* No changes.
|
29
29
|
|
30
30
|
|
31
|
-
## Rails
|
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
|
36
|
+
## Rails 7.0.8 (September 09, 2023) ##
|
44
37
|
|
45
|
-
*
|
38
|
+
* Fix `form_for` missing the hidden `_method` input for models with a
|
39
|
+
namespaced route.
|
46
40
|
|
41
|
+
*Hartley McGuire*
|
47
42
|
|
48
|
-
|
43
|
+
* Fix `render collection: @records, cache: true` inside `jbuilder` templates
|
49
44
|
|
50
|
-
|
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
|
50
|
+
## Rails 7.0.7.2 (August 22, 2023) ##
|
54
51
|
|
55
52
|
* No changes.
|
56
53
|
|
57
54
|
|
58
|
-
## Rails
|
55
|
+
## Rails 7.0.7.1 (August 22, 2023) ##
|
59
56
|
|
60
57
|
* No changes.
|
61
58
|
|
62
59
|
|
63
|
-
## Rails
|
60
|
+
## Rails 7.0.7 (August 09, 2023) ##
|
64
61
|
|
65
|
-
* Fix
|
62
|
+
* Fix `render collection: @records, cache: true` to cache fragments as bare strings
|
66
63
|
|
67
|
-
|
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
|
-
|
66
|
+
*Jean Boussier*
|
73
67
|
|
74
|
-
|
68
|
+
* Don't double-encode nested `field_id` and `field_name` index values
|
75
69
|
|
76
|
-
|
77
|
-
|
70
|
+
Pass `index: @options` as a default keyword argument to `field_id` and
|
71
|
+
`field_name` view helper methods.
|
78
72
|
|
79
|
-
*
|
73
|
+
*Sean Doyle*
|
80
74
|
|
81
|
-
* Add `autocomplete="off"` to all generated hidden fields.
|
82
75
|
|
83
|
-
|
76
|
+
## Rails 7.0.6 (June 29, 2023) ##
|
84
77
|
|
85
|
-
|
78
|
+
* No changes.
|
86
79
|
|
87
|
-
* Fix `current_page?` when URL has trailing slash.
|
88
80
|
|
89
|
-
|
90
|
-
and is an absolute URL or also has query params.
|
81
|
+
## Rails 7.0.5.1 (June 26, 2023) ##
|
91
82
|
|
92
|
-
|
83
|
+
* No changes.
|
93
84
|
|
94
|
-
*Jonathan Hefner*
|
95
85
|
|
86
|
+
## Rails 7.0.5 (May 24, 2023) ##
|
96
87
|
|
97
|
-
|
88
|
+
* `FormBuilder#id` finds id set by `form_for` and `form_with`.
|
98
89
|
|
99
|
-
*
|
90
|
+
*Matt Polito*
|
100
91
|
|
92
|
+
* Allow all available locales for template lookups.
|
101
93
|
|
102
|
-
|
94
|
+
*Ben Dilley*
|
103
95
|
|
104
|
-
*
|
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
|
-
|
104
|
+
*Chris Gunther*
|
108
105
|
|
109
|
-
* No changes.
|
110
106
|
|
107
|
+
## Rails 7.0.4.3 (March 13, 2023) ##
|
111
108
|
|
112
|
-
|
109
|
+
* Ignore certain data-* attributes in rails-ujs when element is contenteditable
|
113
110
|
|
114
|
-
|
111
|
+
[CVE-2023-23913]
|
115
112
|
|
116
113
|
|
117
|
-
## Rails
|
114
|
+
## Rails 7.0.4.2 (January 24, 2023) ##
|
118
115
|
|
119
116
|
* No changes.
|
120
117
|
|
121
118
|
|
122
|
-
## Rails
|
119
|
+
## Rails 7.0.4.1 (January 17, 2023) ##
|
123
120
|
|
124
121
|
* No changes.
|
125
122
|
|
126
123
|
|
127
|
-
## Rails
|
124
|
+
## Rails 7.0.4 (September 09, 2022) ##
|
128
125
|
|
129
|
-
*
|
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
|
-
|
135
|
+
*Sean Doyle*
|
133
136
|
|
134
|
-
*
|
135
|
-
translation keys through `I18n.translate` for interpolation.
|
137
|
+
* Strings returned from `strip_tags` are correctly tagged `html_safe?`
|
136
138
|
|
137
|
-
|
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
|
-
|
143
|
+
Fixes [rails/rails-html-sanitizer#124](https://github.com/rails/rails-html-sanitizer/issues/124)
|
140
144
|
|
141
|
-
*
|
145
|
+
*Mike Dalessio*
|
142
146
|
|
143
|
-
|
147
|
+
## Rails 7.0.3.1 (July 12, 2022) ##
|
144
148
|
|
145
|
-
|
149
|
+
* No changes.
|
146
150
|
|
147
151
|
|
148
|
-
## Rails
|
152
|
+
## Rails 7.0.3 (May 09, 2022) ##
|
149
153
|
|
150
|
-
*
|
154
|
+
* Ensure models passed to `form_for` attempt to call `to_model`.
|
151
155
|
|
156
|
+
*Sean Doyle*
|
152
157
|
|
153
|
-
## Rails
|
158
|
+
## Rails 7.0.2.4 (April 26, 2022) ##
|
154
159
|
|
155
|
-
*
|
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
|
-
|
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
|
174
|
+
## Rails 7.0.2.2 (February 11, 2022) ##
|
164
175
|
|
165
176
|
* No changes.
|
166
177
|
|
167
178
|
|
168
|
-
## Rails
|
179
|
+
## Rails 7.0.2.1 (February 11, 2022) ##
|
169
180
|
|
170
181
|
* No changes.
|
171
182
|
|
172
183
|
|
173
|
-
## Rails
|
184
|
+
## Rails 7.0.2 (February 08, 2022) ##
|
174
185
|
|
175
|
-
*
|
186
|
+
* Ensure `preload_link_tag` preloads JavaScript modules correctly.
|
176
187
|
|
177
|
-
*
|
188
|
+
*Máximo Mussini*
|
178
189
|
|
179
|
-
*
|
190
|
+
* Fix `stylesheet_link_tag` and similar helpers are being used to work in objects with
|
191
|
+
a `response` method.
|
180
192
|
|
181
|
-
*
|
193
|
+
*dark-panda*
|
182
194
|
|
183
|
-
* Link preloading keep integrity hashes in the header.
|
184
195
|
|
185
|
-
|
196
|
+
## Rails 7.0.1 (January 06, 2022) ##
|
186
197
|
|
187
|
-
*
|
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
|
-
*
|
200
|
+
*MingyuanQin*
|
192
201
|
|
193
|
-
*
|
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
|
-
|
202
|
-
call safe_list_sanitizer's class method
|
207
|
+
## Rails 7.0.0 (December 15, 2021) ##
|
203
208
|
|
204
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
211
|
-
users because they were forced to handle remote requests.
|
222
|
+
*Sean Doyle*
|
212
223
|
|
213
|
-
|
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
|
-
*
|
226
|
+
*Pedro Moreira*
|
218
227
|
|
219
|
-
* Yield translated strings to calls of `ActionView::FormBuilder#button`
|
220
|
-
when a block is given.
|
221
228
|
|
222
|
-
|
229
|
+
## Rails 7.0.0.rc3 (December 14, 2021) ##
|
223
230
|
|
224
|
-
*
|
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
|
-
|
230
|
-
and make the original available as an alias.
|
234
|
+
## Rails 7.0.0.rc2 (December 14, 2021) ##
|
231
235
|
|
232
|
-
|
233
|
-
# => "foo bar"
|
236
|
+
* No changes.
|
234
237
|
|
235
|
-
|
238
|
+
## Rails 7.0.0.rc1 (December 06, 2021) ##
|
236
239
|
|
237
|
-
*
|
238
|
-
|
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
|
-
*
|
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
|
-
|
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
|
-
*
|
262
|
+
*Sean Doyle*
|
259
263
|
|
260
|
-
|
264
|
+
* Support passing a Symbol as the first argument to `FormBuilder#button`:
|
261
265
|
|
262
|
-
|
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
|
-
*
|
278
|
+
*Sean Doyle*
|
265
279
|
|
266
|
-
*
|
280
|
+
* Introduce the `field_name` view helper, along with the
|
281
|
+
`FormBuilder#field_name` counterpart:
|
267
282
|
|
268
|
-
|
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
|
-
*
|
290
|
+
*Sean Doyle*
|
271
291
|
|
272
|
-
|
292
|
+
* Execute the `ActionView::Base.field_error_proc` within the context of the
|
293
|
+
`ActionView::Base` instance:
|
273
294
|
|
274
|
-
|
295
|
+
```ruby
|
296
|
+
config.action_view.field_error_proc = proc { |html| content_tag(:div, html, class: "field_with_errors") }
|
297
|
+
```
|
275
298
|
|
276
|
-
*
|
299
|
+
*Sean Doyle*
|
277
300
|
|
278
|
-
*
|
301
|
+
* Add support for `button_to ..., authenticity_token: false`
|
279
302
|
|
280
|
-
|
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
|
-
|
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
|
-
|
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
|
-
*
|
314
|
+
*Sean Doyle*
|
287
315
|
|
288
|
-
|
316
|
+
* Support rendering `<form>` elements _without_ `[action]` attributes by:
|
289
317
|
|
290
|
-
*
|
291
|
-
|
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
|
-
*
|
323
|
+
*Sean Doyle*
|
294
324
|
|
295
|
-
*
|
325
|
+
* Add `:day_format` option to `date_select`
|
296
326
|
|
297
|
-
|
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
|
-
*
|
330
|
+
*Shunichi Ikegami*
|
300
331
|
|
301
|
-
|
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
|
-
|
335
|
+
link_to @profile
|
336
|
+
#=> <a href="/profiles/1">Eileen</a>
|
304
337
|
|
305
|
-
|
338
|
+
This assumes the model class implements a `to_s` method like this:
|
306
339
|
|
307
|
-
|
340
|
+
class Profile < ApplicationRecord
|
341
|
+
# ...
|
342
|
+
def to_s
|
343
|
+
name
|
344
|
+
end
|
345
|
+
end
|
308
346
|
|
309
|
-
|
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
|
-
|
350
|
+
link_to @profile, @profile.name
|
351
|
+
#=> <a href="/profiles/1">Eileen</a>
|
312
352
|
|
313
|
-
*
|
353
|
+
*Olivier Lacan*
|
314
354
|
|
315
|
-
*
|
355
|
+
* Support svg unpaired tags for `tag` helper.
|
316
356
|
|
317
|
-
|
357
|
+
tag.svg { tag.use('href' => "#cool-icon") }
|
358
|
+
# => <svg><use href="#cool-icon"></svg>
|
318
359
|
|
319
|
-
*
|
360
|
+
*Oleksii Vasyliev*
|
320
361
|
|
321
|
-
*Rafael Mendonça França*
|
322
362
|
|
323
|
-
|
363
|
+
## Rails 7.0.0.alpha2 (September 15, 2021) ##
|
324
364
|
|
325
|
-
|
365
|
+
* No changes.
|
326
366
|
|
327
|
-
* Make `locals` argument required on `ActionView::Template#initialize`.
|
328
367
|
|
329
|
-
|
368
|
+
## Rails 7.0.0.alpha1 (September 15, 2021) ##
|
330
369
|
|
331
|
-
*
|
370
|
+
* Improves the performance of ActionView::Helpers::NumberHelper formatters by avoiding the use of
|
371
|
+
exceptions as flow control.
|
332
372
|
|
333
|
-
*
|
373
|
+
*Mike Dalessio*
|
334
374
|
|
335
|
-
*
|
375
|
+
* `preload_link_tag` properly inserts `as` attributes for files with `image` MIME types, such as JPG or SVG.
|
336
376
|
|
337
|
-
*
|
377
|
+
*Nate Berkopec*
|
338
378
|
|
339
|
-
*
|
379
|
+
* Add `weekday_options_for_select` and `weekday_select` helper methods. Also adds `weekday_select` to `FormBuilder`.
|
340
380
|
|
341
|
-
*
|
381
|
+
*Drew Bragg*, *Dana Kashubeck*, *Kasper Timm Hansen*
|
342
382
|
|
343
|
-
*
|
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
|
-
*
|
385
|
+
*Ben Toews*, *John Hawthorn*, *Kasper Timm Hansen*, *Joel Hawksley*
|
346
386
|
|
347
|
-
*
|
387
|
+
* Add `include_seconds` option for `time_field`.
|
348
388
|
|
349
|
-
|
389
|
+
<%= form.time_field :foo, include_seconds: false %>
|
390
|
+
# => <input value="16:22" type="time" />
|
350
391
|
|
351
|
-
|
392
|
+
Default includes seconds:
|
352
393
|
|
353
|
-
|
394
|
+
<%= form.time_field :foo %>
|
395
|
+
# => <input value="16:22:01.440" type="time" />
|
354
396
|
|
355
|
-
|
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
|
-
*
|
399
|
+
*Alex Ghiculescu*
|
358
400
|
|
359
|
-
*
|
401
|
+
* Improve error messages when template file does not exist at absolute filepath.
|
360
402
|
|
361
|
-
*
|
403
|
+
*Ted Whang*
|
362
404
|
|
363
|
-
* `
|
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
|
-
|
367
|
-
<span title="<%= resolved_key %>"><%= translation %></span>
|
368
|
-
<% end %>
|
407
|
+
*Jonathan Hefner*
|
369
408
|
|
370
|
-
|
409
|
+
* OpenSSL constants are now used for Digest computations.
|
371
410
|
|
372
|
-
*
|
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
|
-
|
413
|
+
* The `translate` helper now passes `default` values that aren't
|
414
|
+
translation keys through `I18n.translate` for interpolation.
|
378
415
|
|
379
|
-
*
|
416
|
+
*Jonathan Hefner*
|
380
417
|
|
381
|
-
*
|
382
|
-
`
|
418
|
+
* Adds option `extname` to `stylesheet_link_tag` to skip default
|
419
|
+
`.css` extension appended to the stylesheet path.
|
383
420
|
|
384
|
-
|
385
|
-
for missing translations in controllers and views.
|
421
|
+
Before:
|
386
422
|
|
387
|
-
|
423
|
+
```ruby
|
424
|
+
stylesheet_link_tag "style.less"
|
425
|
+
# <link href="/stylesheets/style.less.scss" rel="stylesheet">
|
426
|
+
```
|
388
427
|
|
389
|
-
|
390
|
-
and include (when necessary) the layout's virtual path in notification payloads for collection and partial renders.
|
428
|
+
After:
|
391
429
|
|
392
|
-
|
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
|
-
*
|
435
|
+
*Abhay Nikam*
|
395
436
|
|
396
|
-
|
437
|
+
* Deprecate `render` locals to be assigned to instance variables.
|
397
438
|
|
398
|
-
*
|
399
|
-
passed `default: nil` without a translation matching `I18n#translate`.
|
439
|
+
*Petrik de Heus*
|
400
440
|
|
401
|
-
|
441
|
+
* Remove legacy default `media=screen` from `stylesheet_link_tag`.
|
402
442
|
|
403
|
-
*
|
404
|
-
formats, variants, handlers.
|
443
|
+
*André Luis Leal Cardoso Junior*
|
405
444
|
|
406
|
-
|
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
|
-
|
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
|
-
*
|
459
|
+
*Sean Doyle*
|
411
460
|
|
412
|
-
*
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
*
|
444
|
-
emitted at the `DEBUG` level instead of `INFO`.
|
479
|
+
*Andrew White*
|
445
480
|
|
446
|
-
|
481
|
+
* The `translate` helper now resolves `default` values when a `nil` key is
|
482
|
+
specified, instead of always returning `nil`.
|
447
483
|
|
448
|
-
*
|
484
|
+
*Jonathan Hefner*
|
449
485
|
|
450
|
-
*
|
486
|
+
* Add `config.action_view.image_loading` to configure the default value of
|
487
|
+
the `image_tag` `:loading` option.
|
451
488
|
|
452
|
-
|
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
|
-
*
|
492
|
+
*Jonathan Hefner*
|
455
493
|
|
456
|
-
|
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
|
-
|
459
|
-
|
498
|
+
<%= form_for @post do |f| %>
|
499
|
+
<%# ... %>
|
460
500
|
|
461
|
-
|
501
|
+
<% content_for :sticky_footer do %>
|
502
|
+
<%= form.button(form: f.id) %>
|
503
|
+
<% end %>
|
504
|
+
<% end %>
|
505
|
+
|
506
|
+
*Sean Doyle*
|
462
507
|
|
463
|
-
*
|
508
|
+
* `ActionView::Helpers::FormBuilder#field_id` returns the value generated by
|
509
|
+
the FormBuilder for the given attribute name.
|
464
510
|
|
465
|
-
|
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
|
-
*
|
517
|
+
*Sean Doyle*
|
468
518
|
|
469
|
-
|
519
|
+
* Add `tag.attributes` to transform a Hash into HTML Attributes, ready to be
|
520
|
+
interpolated into ERB.
|
470
521
|
|
471
|
-
|
522
|
+
<input <%= tag.attributes(type: :text, aria: { label: "Search" }) %> >
|
523
|
+
# => <input type="text" aria-label="Search">
|
472
524
|
|
473
|
-
*
|
525
|
+
*Sean Doyle*
|
474
526
|
|
475
527
|
|
476
|
-
Please check [6-
|
528
|
+
Please check [6-1-stable](https://github.com/rails/rails/blob/6-1-stable/actionview/CHANGELOG.md) for previous changes.
|