2022-11-24 03:14:08 +08:00
|
|
|
* Choices of `select` can optionally contain html attributes as the last element
|
|
|
|
of the child arrays when using grouped/nested collections
|
2021-08-16 04:43:20 +08:00
|
|
|
|
2022-11-24 03:14:08 +08:00
|
|
|
```erb
|
|
|
|
<%= form.select :foo, [["North America", [["United States","US"],["Canada","CA"]], { disabled: "disabled" }]] %>
|
|
|
|
# => <select><optgroup label="North America" disabled="disabled"><option value="US">United States</option><option value="CA">Canada</option></optgroup></select>
|
|
|
|
```
|
2021-08-16 04:43:20 +08:00
|
|
|
|
|
|
|
*Chris Gunther*
|
2021-10-09 09:36:49 +08:00
|
|
|
|
2022-07-06 06:16:22 +08:00
|
|
|
* `check_box_tag` and `radio_button_tag` now accept `checked` as a keyword argument
|
|
|
|
|
2022-11-24 03:14:08 +08:00
|
|
|
This is to make the API more consistent with the `FormHelper` variants. You can now
|
|
|
|
provide `checked` as a positional or keyword argument:
|
2022-07-06 06:16:22 +08:00
|
|
|
|
|
|
|
```erb
|
|
|
|
= check_box_tag "admin", "1", false
|
|
|
|
= check_box_tag "admin", "1", checked: false
|
|
|
|
|
|
|
|
= radio_button_tag 'favorite_color', 'maroon', false
|
|
|
|
= radio_button_tag 'favorite_color', 'maroon', checked: false
|
|
|
|
```
|
|
|
|
|
|
|
|
*Alex Ghiculescu*
|
|
|
|
|
2022-09-20 01:44:01 +08:00
|
|
|
* Allow passing a class to `dom_id`.
|
|
|
|
You no longer need to call `new` when passing a class to `dom_id`.
|
|
|
|
This makes `dom_id` behave like `dom_class` in this regard.
|
|
|
|
Apart from saving a few keystrokes, it prevents Ruby from needing
|
|
|
|
to instantiate a whole new object just to generate a string.
|
|
|
|
|
|
|
|
Before:
|
|
|
|
```ruby
|
|
|
|
dom_id(Post) # => NoMethodError: undefined method `to_key' for Post:Class
|
|
|
|
```
|
|
|
|
|
|
|
|
After:
|
|
|
|
```ruby
|
|
|
|
dom_id(Post) # => "new_post"
|
|
|
|
```
|
|
|
|
|
|
|
|
*Goulven Champenois*
|
|
|
|
|
2022-09-09 07:44:09 +08:00
|
|
|
* Report `:locals` as part of the data returned by ActionView render instrumentation.
|
|
|
|
|
|
|
|
Before:
|
|
|
|
```ruby
|
|
|
|
{
|
|
|
|
identifier: "/Users/adam/projects/notifications/app/views/posts/index.html.erb",
|
|
|
|
layout: "layouts/application"
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
After:
|
|
|
|
```ruby
|
|
|
|
{
|
|
|
|
identifier: "/Users/adam/projects/notifications/app/views/posts/index.html.erb",
|
|
|
|
layout: "layouts/application",
|
|
|
|
locals: {foo: "bar"}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
*Aaron Gough*
|
|
|
|
|
2022-09-05 01:44:00 +08:00
|
|
|
* Strip `break_sequence` at the end of `word_wrap`.
|
|
|
|
|
|
|
|
This fixes a bug where `word_wrap` didn't properly strip off break sequences that had printable characters.
|
|
|
|
|
|
|
|
For example, compare the outputs of this template:
|
|
|
|
|
|
|
|
```erb
|
|
|
|
# <%= word_wrap("11 22\n33 44", line_width: 2, break_sequence: "\n# ") %>
|
|
|
|
```
|
|
|
|
|
|
|
|
Before:
|
|
|
|
|
|
|
|
```
|
|
|
|
# 11
|
|
|
|
# 22
|
|
|
|
#
|
|
|
|
# 33
|
|
|
|
# 44
|
|
|
|
#
|
|
|
|
```
|
|
|
|
|
|
|
|
After:
|
|
|
|
|
|
|
|
```
|
|
|
|
# 11
|
|
|
|
# 22
|
|
|
|
# 33
|
|
|
|
# 44
|
|
|
|
```
|
|
|
|
|
|
|
|
*Max Chernyak*
|
|
|
|
|
2022-08-02 07:23:47 +08:00
|
|
|
* Allow templates to set strict `locals`.
|
2022-07-13 21:53:55 +08:00
|
|
|
|
|
|
|
By default, templates will accept any `locals` as keyword arguments. To define what `locals` a template accepts, add a `locals` magic comment:
|
|
|
|
|
|
|
|
```erb
|
|
|
|
<%# locals: (message:) -%>
|
|
|
|
<%= message %>
|
|
|
|
```
|
|
|
|
|
|
|
|
Default values can also be provided:
|
|
|
|
|
|
|
|
```erb
|
|
|
|
<%# locals: (message: "Hello, world!") -%>
|
|
|
|
<%= message %>
|
|
|
|
```
|
|
|
|
|
|
|
|
Or `locals` can be disabled entirely:
|
|
|
|
|
|
|
|
```erb
|
|
|
|
<%# locals: () %>
|
|
|
|
```
|
|
|
|
|
|
|
|
*Joel Hawksley*
|
|
|
|
|
2022-05-27 14:31:02 +08:00
|
|
|
* Add `include_seconds` option for `datetime_local_field`
|
|
|
|
|
|
|
|
This allows to omit seconds part in the input field, by passing `include_seconds: false`
|
|
|
|
|
|
|
|
*Wojciech Wnętrzak*
|
|
|
|
|
2022-06-15 20:32:16 +08:00
|
|
|
* Guard against `ActionView::Helpers::FormTagHelper#field_name` calls with nil
|
|
|
|
`object_name` arguments. For example:
|
|
|
|
|
|
|
|
```erb
|
|
|
|
<%= fields do |f| %>
|
|
|
|
<%= f.field_name :body %>
|
|
|
|
<% end %>
|
|
|
|
```
|
|
|
|
|
|
|
|
*Sean Doyle*
|
|
|
|
|
2022-05-30 23:10:17 +08:00
|
|
|
* Strings returned from `strip_tags` are correctly tagged `html_safe?`
|
|
|
|
|
|
|
|
Because these strings contain no HTML elements and the basic entities are escaped, they are safe
|
|
|
|
to be included as-is as PCDATA in HTML content. Tagging them as html-safe avoids double-escaping
|
|
|
|
entities when being concatenated to a SafeBuffer during rendering.
|
|
|
|
|
|
|
|
Fixes [rails/rails-html-sanitizer#124](https://github.com/rails/rails-html-sanitizer/issues/124)
|
|
|
|
|
|
|
|
*Mike Dalessio*
|
|
|
|
|
2022-02-18 04:53:09 +08:00
|
|
|
* Move `convert_to_model` call from `form_for` into `form_with`
|
|
|
|
|
|
|
|
Now that `form_for` is implemented in terms of `form_with`, remove the
|
|
|
|
`convert_to_model` call from `form_for`.
|
|
|
|
|
|
|
|
*Sean Doyle*
|
|
|
|
|
2022-01-05 23:37:54 +08:00
|
|
|
* Fix and add protections for XSS in `ActionView::Helpers` and `ERB::Util`.
|
|
|
|
|
|
|
|
Escape dangerous characters in names of tags and names of attributes in the
|
|
|
|
tag helpers, following the XML specification. Rename the option
|
|
|
|
`:escape_attributes` to `:escape`, to simplify by applying the option to the
|
|
|
|
whole tag.
|
|
|
|
|
|
|
|
*Álvaro Martín Fraguas*
|
|
|
|
|
2022-01-06 03:06:52 +08:00
|
|
|
* Extend audio_tag and video_tag to accept Active Storage attachments.
|
|
|
|
|
|
|
|
Now it's possible to write
|
|
|
|
|
|
|
|
```ruby
|
|
|
|
audio_tag(user.audio_file)
|
|
|
|
video_tag(user.video_file)
|
|
|
|
```
|
|
|
|
|
|
|
|
Instead of
|
|
|
|
|
|
|
|
```ruby
|
|
|
|
audio_tag(polymorphic_path(user.audio_file))
|
|
|
|
video_tag(polymorphic_path(user.video_file))
|
|
|
|
```
|
|
|
|
|
|
|
|
`image_tag` already supported that, so this follows the same pattern.
|
|
|
|
|
|
|
|
*Matheus Richard*
|
|
|
|
|
2022-02-04 03:05:48 +08:00
|
|
|
* Ensure models passed to `form_for` attempt to call `to_model`.
|
2021-10-09 09:36:49 +08:00
|
|
|
|
2022-02-04 03:05:48 +08:00
|
|
|
*Sean Doyle*
|
2021-10-09 09:36:49 +08:00
|
|
|
|
2021-12-07 23:52:30 +08:00
|
|
|
Please check [7-0-stable](https://github.com/rails/rails/blob/7-0-stable/actionview/CHANGELOG.md) for previous changes.
|