2020-11-02 16:12:47 -05:00
|
|
|
## Rails 6.1.0.rc1 (November 02, 2020) ##
|
|
|
|
|
2020-02-22 02:14:42 -05:00
|
|
|
* Yield translated strings to calls of `ActionView::FormBuilder#button`
|
|
|
|
when a block is given.
|
|
|
|
|
|
|
|
*Sean Doyle*
|
|
|
|
|
Yield `Tags::Label::LabelBuilder#translations`
When translating a `<label>` element's contents, it is difficult (or
"possible", yet undocumented) to make the translation text available to
a block scope.
For instance, when rendering a `rich_text_area`, passing the
`aria-label` attribute might be important.
Prior to this commit, doing so would require a double lookup of the
translation key:
```erb
<%# one time here, implicitly %>
<%= form.label(:content) do %>
<%= form.rich_text_area(
:content,
# one time here, explicitly
"aria-label" => translate("helpers.label.post.content"),
) %>
<% end %>
```
The current implementation of the `#label` helper method already yields
an instance of `ActionView::Helpers::Tags::Label::LabelBuilder`, but
that class is undocumented. Instance of that class respond to
`#translation` calls, which will return the translated text content.
By aliasing `#translation` to `#to_s`, we're able to expose that value
without the burden of exposing an additional class to the public API.
Instead, view-level interpolation (either `<%= %>`, `#{ }`, or direct
calls to [`capture`][capture] will coerce the value to a String, and
implicitly invoke `#translation`.
The new view code might look something like this:
```erb
<%= form.label(:content) do |label| %>
<%= form.rich_text_area(:content, "aria-label" => label) %>
<% end %>
```
Callers of the helper are still free to omit the block parameter.
[capture]: https://api.rubyonrails.org/classes/ActionView/Helpers/CaptureHelper.html#method-i-capture
2020-02-22 01:45:00 -05:00
|
|
|
* Alias `ActionView::Helpers::Tags::Label::LabelBuilder#translation` to
|
|
|
|
`#to_s` so that `form.label` calls can yield that value to their blocks.
|
|
|
|
|
|
|
|
*Sean Doyle*
|
|
|
|
|
2020-08-30 22:15:36 -04:00
|
|
|
* Rename the new `TagHelper#class_names` method to `TagHelper#token_list`,
|
|
|
|
and make the original available as an alias.
|
|
|
|
|
|
|
|
token_list("foo", "foo bar")
|
|
|
|
# => "foo bar"
|
|
|
|
|
|
|
|
*Sean Doyle*
|
|
|
|
|
Serialize aria- namespaced list attributes
Summary
===
Prior to this commit, calls passing `aria: { labelledby: [...] }`
serialized the `aria-labelledby` Array value as JSON.
This commit introduces special case logic to serialize `aria-` prefixed
`TrueClass`, `FalseClass`, `Hash`, and `Array` values more
appropriately.
An element's [`aria-labelledby` attribute][aria-labelledby] and
[`aria-describedby` attribute][aria-describedby] can accept a
space-delimited list of identifier values (much like the [`class`
attribute][class] accepts a space delimited [`DOMTokenList`
value][DOMTokenList]).
Similarly, there are [no boolean `aria-` attributes][aria-attributes]
(only `true`, `false`, or undefined), so this commit serializes `true`
to `"true"` and `false` to `"false"`.
Testing
---
This change moves an assertion _outside_ of a loop over `["aria",
:aria]`. Prior to this change, the second assertion within the loop
wasn't utilizing the iterated value as a Hash key. That is to say:
`aria:` (where an `aria` local variable is declared) is not equivalent
an equivalent syntax to `aria =>`.
Since the migration to `**options` in response to Ruby 2.7 deprecations,
invoking `tag.a("aria" => {...})` incorrectly coerces the `"aria" =>
{...}` has to be the `TagBuilder#a` method `content = nil` ordered
argument, instead of its `options` keyword arguments. This commit does
not modify that behavior, but it _does_ move the assertion outside the
block so that it isn't run unnecessarily.
[aria-labelledby]: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques/Using_the_aria-labelledby_attribute
[aria-describedby]: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques/Using_the_aria-describedby_attribute
[aria-attributes]: https://www.w3.org/TR/wai-aria-1.1/#propcharacteristic_value
[class]: https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/class
[DOMTokenList]: https://developer.mozilla.org/en-US/docs/Web/API/DOMTokenList
[class_names]: https://edgeapi.rubyonrails.org/classes/ActionView/Helpers/TagHelper.html#method-i-class_names
2020-10-28 21:41:21 -04:00
|
|
|
* ARIA Array and Hash attributes are treated as space separated `DOMTokenList`
|
|
|
|
values. This is useful when declaring lists of label text identifiers in
|
|
|
|
`aria-labelledby` or `aria-describedby`.
|
|
|
|
|
|
|
|
tag.input type: 'checkbox', name: 'published', aria: {
|
|
|
|
invalid: @post.errors[:published].any?,
|
|
|
|
labelledby: ['published_context', 'published_label'],
|
|
|
|
describedby: { published_errors: @post.errors[:published].any? }
|
|
|
|
}
|
|
|
|
#=> <input
|
|
|
|
type="checkbox" name="published" aria-invalid="true"
|
|
|
|
aria-labelledby="published_context published_label"
|
|
|
|
aria-describedby="published_errors"
|
|
|
|
>
|
|
|
|
|
|
|
|
*Sean Doyle*
|
|
|
|
|
2020-05-06 20:19:54 -04:00
|
|
|
* Remove deprecated `escape_whitelist` from `ActionView::Template::Handlers::ERB`.
|
|
|
|
|
|
|
|
*Rafael Mendonça França*
|
|
|
|
|
2020-05-06 18:21:19 -04:00
|
|
|
* Remove deprecated `find_all_anywhere` from `ActionView::Resolver`.
|
|
|
|
|
|
|
|
*Rafael Mendonça França*
|
|
|
|
|
2020-05-06 18:18:01 -04:00
|
|
|
* Remove deprecated `formats` from `ActionView::Template::HTML`.
|
|
|
|
|
|
|
|
*Rafael Mendonça França*
|
|
|
|
|
2020-05-06 18:16:38 -04:00
|
|
|
* Remove deprecated `formats` from `ActionView::Template::RawFile`.
|
|
|
|
|
|
|
|
*Rafael Mendonça França*
|
|
|
|
|
2020-05-06 18:15:09 -04:00
|
|
|
* Remove deprecated `formats` from `ActionView::Template::Text`.
|
|
|
|
|
|
|
|
*Rafael Mendonça França*
|
|
|
|
|
2020-05-06 18:10:28 -04:00
|
|
|
* Remove deprecated `find_file` from `ActionView::PathSet`.
|
|
|
|
|
|
|
|
*Rafael Mendonça França*
|
|
|
|
|
2020-05-06 17:57:29 -04:00
|
|
|
* Remove deprecated `rendered_format` from `ActionView::LookupContext`.
|
|
|
|
|
|
|
|
*Rafael Mendonça França*
|
|
|
|
|
2020-05-06 17:53:39 -04:00
|
|
|
* Remove deprecated `find_file` from `ActionView::ViewPaths`.
|
|
|
|
|
|
|
|
*Rafael Mendonça França*
|
|
|
|
|
2020-05-06 17:31:39 -04:00
|
|
|
* Require that `ActionView::Base` subclasses implement `#compiled_method_container`.
|
|
|
|
|
|
|
|
*Rafael Mendonça França*
|
|
|
|
|
2020-05-06 16:28:34 -04:00
|
|
|
* Remove deprecated support to pass an object that is not a `ActionView::LookupContext` as the first argument
|
|
|
|
in `ActionView::Base#initialize`.
|
2020-08-30 22:15:36 -04:00
|
|
|
|
2020-05-06 16:28:34 -04:00
|
|
|
*Rafael Mendonça França*
|
|
|
|
|
2020-05-06 13:21:07 -04:00
|
|
|
* Remove deprecated `format` argument `ActionView::Base#initialize`.
|
|
|
|
|
|
|
|
*Rafael Mendonça França*
|
|
|
|
|
2020-05-05 19:33:47 -04:00
|
|
|
* Remove deprecated `ActionView::Template#refresh`.
|
|
|
|
|
|
|
|
*Rafael Mendonça França*
|
|
|
|
|
2020-05-05 19:32:32 -04:00
|
|
|
* Remove deprecated `ActionView::Template#original_encoding`.
|
|
|
|
|
|
|
|
*Rafael Mendonça França*
|
|
|
|
|
2020-05-05 19:31:11 -04:00
|
|
|
* Remove deprecated `ActionView::Template#variants`.
|
|
|
|
|
|
|
|
*Rafael Mendonça França*
|
|
|
|
|
2020-05-05 19:29:59 -04:00
|
|
|
* Remove deprecated `ActionView::Template#formats`.
|
|
|
|
|
|
|
|
*Rafael Mendonça França*
|
|
|
|
|
2020-05-05 19:27:21 -04:00
|
|
|
* Remove deprecated `ActionView::Template#virtual_path=`.
|
|
|
|
|
|
|
|
*Rafael Mendonça França*
|
|
|
|
|
2020-05-05 19:23:24 -04:00
|
|
|
* Remove deprecated `ActionView::Template#updated_at`.
|
|
|
|
|
|
|
|
*Rafael Mendonça França*
|
|
|
|
|
|
|
|
* Remove deprecated `updated_at` argument required on `ActionView::Template#initialize`.
|
|
|
|
|
|
|
|
*Rafael Mendonça França*
|
|
|
|
|
2020-05-05 19:08:13 -04:00
|
|
|
* Make `locals` argument required on `ActionView::Template#initialize`.
|
|
|
|
|
|
|
|
*Rafael Mendonça França*
|
|
|
|
|
2020-05-05 17:29:27 -04:00
|
|
|
* Remove deprecated `ActionView::Template.finalize_compiled_template_methods`.
|
|
|
|
|
|
|
|
*Rafael Mendonça França*
|
|
|
|
|
|
|
|
* Remove deprecated `config.action_view.finalize_compiled_template_methods`
|
|
|
|
|
|
|
|
*Rafael Mendonça França*
|
|
|
|
|
2020-05-05 16:37:29 -04:00
|
|
|
* Remove deprecated support to calling `ActionView::ViewPaths#with_fallback` with a block.
|
|
|
|
|
|
|
|
*Rafael Mendonça França*
|
|
|
|
|
2020-05-05 16:13:01 -04:00
|
|
|
* Remove deprecated support to passing absolute paths to `render template:`.
|
|
|
|
|
|
|
|
*Rafael Mendonça França*
|
|
|
|
|
2020-05-05 15:58:55 -04:00
|
|
|
* Remove deprecated support to passing relative paths to `render file:`.
|
|
|
|
|
|
|
|
*Rafael Mendonça França*
|
|
|
|
|
2020-05-05 11:20:48 -04:00
|
|
|
* Remove support to template handlers that don't accept two arguments.
|
|
|
|
|
|
|
|
*Rafael Mendonça França*
|
|
|
|
|
2020-05-05 01:45:21 -04:00
|
|
|
* Remove deprecated pattern argument in `ActionView::Template::PathResolver`.
|
|
|
|
|
|
|
|
*Rafael Mendonça França*
|
|
|
|
|
2020-05-05 01:28:48 -04:00
|
|
|
* Remove deprecated support to call private methods from object in some view helpers.
|
|
|
|
|
|
|
|
*Rafael Mendonça França*
|
|
|
|
|
Extend `ActionView::Helpers#translate` to yield
This commit extends the `ActionView::Helpers#translate` (and by way of
alias, `#t`) helper methods to accept blocks.
When invoked with a block, the `translate` call will yield the
translated text as its first block argument, along with the resolved
translation key as its second:
```erb
<%= translate(".key") do |translation, resolved_key| %>
<span data-i18n-key="<%= resolved_key %>"><%= translation %></span>
<% end %>
```
In cases where relative translation keys are foregone in lieu of fully
qualified keys, or if the caller is not interested in the resolved key,
the second block argument can be omitted:
```erb
<%= translate("action.template.key") do |translation| %>
<p><%= translation %></p>
<p><%= translation %>, but a second time</p>
<% end %>
```
A benefit of yielding the translation is that it enabled template-local
variable re-use. Alternatively, [`Object#tap`][tap] could be used.
Prior to this commit, however, the resolution of the translation key was
internal to `ActionView`, and unavailable to the caller (unless they
were willing to explicitly determine the resolved key themselves). By
making it available as a block parameter, it could be used to annotate
the translated value in the resulting elements.
[tap]: https://ruby-doc.org/core-2.7.0/Object.html#method-i-tap
2020-03-06 10:34:26 -05:00
|
|
|
* `ActionView::Helpers::TranslationHelper#translate` accepts a block, yielding
|
|
|
|
the translated text and the fully resolved translation key:
|
|
|
|
|
|
|
|
<%= translate(".relative_key") do |translation, resolved_key| %>
|
|
|
|
<span title="<%= resolved_key %>"><%= translation %></span>
|
|
|
|
<% end %>
|
|
|
|
|
|
|
|
*Sean Doyle*
|
|
|
|
|
2020-04-24 17:29:00 -04:00
|
|
|
* Ensure cache fragment digests include all relevant template dependencies when
|
|
|
|
fragments are contained in a block passed to the render helper. Remove the
|
|
|
|
virtual_path keyword arguments found in CacheHelper as they no longer possess
|
|
|
|
any function following 1581cab.
|
|
|
|
|
2020-06-06 23:58:22 -04:00
|
|
|
Fixes #38984.
|
2020-04-24 17:29:00 -04:00
|
|
|
|
|
|
|
*Aaron Lipman*
|
|
|
|
|
2017-12-26 19:51:42 -05:00
|
|
|
* Deprecate `config.action_view.raise_on_missing_translations` in favor of
|
|
|
|
`config.i18n.raise_on_missing_translations`.
|
|
|
|
|
|
|
|
New generalized configuration option now determines whether an error should be raised
|
|
|
|
for missing translations in controllers and views.
|
|
|
|
|
|
|
|
*fatkodima*
|
|
|
|
|
2020-06-06 23:58:22 -04:00
|
|
|
* Instrument layout rendering in `TemplateRenderer#render_with_layout` as `render_layout.action_view`,
|
|
|
|
and include (when necessary) the layout's virtual path in notification payloads for collection and partial renders.
|
2020-04-20 16:28:35 -04:00
|
|
|
|
|
|
|
*Zach Kemp*
|
|
|
|
|
2020-05-09 02:22:12 -04:00
|
|
|
* `ActionView::Base.annotate_rendered_view_with_filenames` annotates HTML output with template file names.
|
2020-03-30 16:16:31 -04:00
|
|
|
|
|
|
|
*Joel Hawksley*, *Aaron Patterson*
|
|
|
|
|
2019-12-05 17:13:28 -05:00
|
|
|
* `ActionView::Helpers::TranslationHelper#translate` returns nil when
|
|
|
|
passed `default: nil` without a translation matching `I18n#translate`.
|
|
|
|
|
|
|
|
*Stefan Wrobel*
|
|
|
|
|
2019-10-24 16:51:49 -04:00
|
|
|
* `OptimizedFileSystemResolver` prefers template details in order of locale,
|
|
|
|
formats, variants, handlers.
|
|
|
|
|
|
|
|
*Iago Pimenta*
|
|
|
|
|
2019-12-11 11:20:38 -05:00
|
|
|
* Added `class_names` helper to create a CSS class value with conditional classes.
|
|
|
|
|
|
|
|
*Joel Hawksley*, *Aaron Patterson*
|
|
|
|
|
2019-12-03 13:18:01 -05:00
|
|
|
* Add support for conditional values to TagBuilder.
|
|
|
|
|
|
|
|
*Joel Hawksley*
|
2019-12-11 11:20:38 -05:00
|
|
|
|
`ActionView::Helpers::FormOptionsHelper#select` should mark option for `nil` as selected
```ruby
@post = Post.new
@post.category = nil
# Before
select("post", "category", none: nil, programming: 1, economics: 2)
# =>
# <select name="post[category]" id="post_category">
# <option value="">none</option>
# <option value="1">programming</option>
# <option value="2">economics</option>
# </select>
# After
select("post", "category", none: nil, programming: 1, economics: 2)
# =>
# <select name="post[category]" id="post_category">
# <option selected="selected" value="">none</option>
# <option value="1">programming</option>
# <option value="2">economics</option>
# </select>
```
To get the same result without these changes we can set `:selected` as `@post.category.to_s`:
```ruby
select("post", "category", {none: nil, programming: 1, economics: 2}, {selected: @post.category.to_s}
```
2018-12-27 11:18:32 -05:00
|
|
|
* `ActionView::Helpers::FormOptionsHelper#select` should mark option for `nil` as selected.
|
|
|
|
|
|
|
|
```ruby
|
|
|
|
@post = Post.new
|
|
|
|
@post.category = nil
|
|
|
|
|
|
|
|
# Before
|
|
|
|
select("post", "category", none: nil, programming: 1, economics: 2)
|
|
|
|
# =>
|
|
|
|
# <select name="post[category]" id="post_category">
|
|
|
|
# <option value="">none</option>
|
|
|
|
# <option value="1">programming</option>
|
|
|
|
# <option value="2">economics</option>
|
|
|
|
# </select>
|
|
|
|
|
|
|
|
# After
|
|
|
|
select("post", "category", none: nil, programming: 1, economics: 2)
|
|
|
|
# =>
|
|
|
|
# <select name="post[category]" id="post_category">
|
|
|
|
# <option selected="selected" value="">none</option>
|
|
|
|
# <option value="1">programming</option>
|
|
|
|
# <option value="2">economics</option>
|
|
|
|
# </select>
|
|
|
|
```
|
|
|
|
|
|
|
|
*bogdanvlviv*
|
|
|
|
|
2019-08-25 14:39:58 -04:00
|
|
|
* Log lines for partial renders and started template renders are now
|
|
|
|
emitted at the `DEBUG` level instead of `INFO`.
|
|
|
|
|
|
|
|
Completed template renders are still logged at the `INFO` level.
|
|
|
|
|
|
|
|
*DHH*
|
|
|
|
|
2019-05-14 00:09:39 -04:00
|
|
|
* ActionView::Helpers::SanitizeHelper: support rails-html-sanitizer 1.1.0.
|
|
|
|
|
|
|
|
*Juanito Fatas*
|
|
|
|
|
2019-11-23 19:20:00 -05:00
|
|
|
* Added `phone_to` helper method to create a link from mobile numbers.
|
2019-07-26 14:54:57 -04:00
|
|
|
|
|
|
|
*Pietro Moro*
|
|
|
|
|
2019-06-21 15:04:28 -04:00
|
|
|
* annotated_source_code returns an empty array so TemplateErrors without a
|
|
|
|
template in the backtrace are surfaced properly by DebugExceptions.
|
|
|
|
|
|
|
|
*Guilherme Mansur*, *Kasper Timm Hansen*
|
|
|
|
|
2019-06-19 13:42:52 -04:00
|
|
|
* Add autoload for SyntaxErrorInTemplate so syntax errors are correctly raised by DebugExceptions.
|
|
|
|
|
|
|
|
*Guilherme Mansur*, *Gannon McGibbon*
|
|
|
|
|
2019-11-23 19:20:00 -05:00
|
|
|
* `RenderingHelper` supports rendering objects that `respond_to?` `:render_in`.
|
2019-05-29 15:03:54 -04:00
|
|
|
|
|
|
|
*Joel Hawksley*, *Natasha Umer*, *Aaron Patterson*, *Shawn Allen*, *Emily Plummer*, *Diana Mounter*, *John Hawthorn*, *Nathan Herald*, *Zaid Zawaideh*, *Zach Ahn*
|
2019-12-03 13:18:01 -05:00
|
|
|
|
2019-05-22 04:21:59 -04:00
|
|
|
* Fix `select_tag` so that it doesn't change `options` when `include_blank` is present.
|
|
|
|
|
|
|
|
*Younes SERRAJ*
|
2019-04-19 12:34:53 -04:00
|
|
|
|
|
|
|
|
2019-04-24 15:57:14 -04:00
|
|
|
Please check [6-0-stable](https://github.com/rails/rails/blob/6-0-stable/actionview/CHANGELOG.md) for previous changes.
|