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