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