rails--rails/actionview/CHANGELOG.md

151 lines
4.8 KiB
Markdown
Raw Normal View History

* Make `locals` argument required on `ActionView::Template#initialize`.
*Rafael Mendonça França*
* 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*
* Remove deprecated support to calling `ActionView::ViewPaths#with_fallback` with a block.
*Rafael Mendonça França*
* Remove deprecated support to passing absolute paths to `render template:`.
*Rafael Mendonça França*
* Remove deprecated support to passing relative paths to `render file:`.
*Rafael Mendonça França*
* Remove support to template handlers that don't accept two arguments.
*Rafael Mendonça França*
* Remove deprecated pattern argument in `ActionView::Template::PathResolver`.
*Rafael Mendonça França*
* Remove deprecated support to call private methods from object in some view helpers.
*Rafael Mendonça França*
* `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*
Ensure cache fragment digests include all templates A Rails view may rely on several templates (e.g. layouts and partials) in addition to the template for the action being rendered (e.g. "show.html.erb"). To track which view file is currently being rendered for the purpose of generating template tree digests used in cache fragment keys, Action View uses a stack, the top item of which is accessed via the @current_template variable (introduced in 1581cab). Consider the following template: <!-- home.html.erb --> <%= render layout: "wrapper" do %> <%= cache "foo" %> HOME <%= end %> <%= end %> Inside the block passed to the render helper, @current_template corresponds to the wrapper.html.erb template instead of home.html.erb. As wrapper.html.erb is then used as the root node for generating the template tree digest used in the cache fragment key, the cache fragment fails to expire upon changes to home.html.erb. Additionally, should a second template use the wrapper.html.erb layout and contain a cache fragment with the same key, the cache fragment keys for both templates will be identical - causing cached content to "leak" from one view to another (as described in #38984). This commit skips adding templates to the stack when rendered as a layout with a block via the render helper, ensuring correct and unique cache fragment digests. Additionally, the virtual_path keyword arguments found in CacheHelper and all references to the are removed as they no longer possess any function. (Following the introduction of @current_template, virtual_path is accessed via @current_template.virtual_path rather than as a standalone variable.)
2020-04-24 21:29:00 +00: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-07 03:58:22 +00:00
Fixes #38984.
Ensure cache fragment digests include all templates A Rails view may rely on several templates (e.g. layouts and partials) in addition to the template for the action being rendered (e.g. "show.html.erb"). To track which view file is currently being rendered for the purpose of generating template tree digests used in cache fragment keys, Action View uses a stack, the top item of which is accessed via the @current_template variable (introduced in 1581cab). Consider the following template: <!-- home.html.erb --> <%= render layout: "wrapper" do %> <%= cache "foo" %> HOME <%= end %> <%= end %> Inside the block passed to the render helper, @current_template corresponds to the wrapper.html.erb template instead of home.html.erb. As wrapper.html.erb is then used as the root node for generating the template tree digest used in the cache fragment key, the cache fragment fails to expire upon changes to home.html.erb. Additionally, should a second template use the wrapper.html.erb layout and contain a cache fragment with the same key, the cache fragment keys for both templates will be identical - causing cached content to "leak" from one view to another (as described in #38984). This commit skips adding templates to the stack when rendered as a layout with a block via the render helper, ensuring correct and unique cache fragment digests. Additionally, the virtual_path keyword arguments found in CacheHelper and all references to the are removed as they no longer possess any function. (Following the introduction of @current_template, virtual_path is accessed via @current_template.virtual_path rather than as a standalone variable.)
2020-04-24 21:29:00 +00:00
*Aaron Lipman*
* 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-07 03:58:22 +00: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.
*Zach Kemp*
* `ActionView::Base.annotate_rendered_view_with_filenames` annotates HTML output with template file names.
*Joel Hawksley*, *Aaron Patterson*
* `ActionView::Helpers::TranslationHelper#translate` returns nil when
passed `default: nil` without a translation matching `I18n#translate`.
*Stefan Wrobel*
* `OptimizedFileSystemResolver` prefers template details in order of locale,
formats, variants, handlers.
*Iago Pimenta*
* Added `class_names` helper to create a CSS class value with conditional classes.
*Joel Hawksley*, *Aaron Patterson*
* Add support for conditional values to TagBuilder.
*Joel Hawksley*
* `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*
* 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*
* ActionView::Helpers::SanitizeHelper: support rails-html-sanitizer 1.1.0.
*Juanito Fatas*
2019-11-24 00:20:00 +00:00
* Added `phone_to` helper method to create a link from mobile numbers.
*Pietro Moro*
* 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*
* Add autoload for SyntaxErrorInTemplate so syntax errors are correctly raised by DebugExceptions.
*Guilherme Mansur*, *Gannon McGibbon*
2019-11-24 00:20:00 +00:00
* `RenderingHelper` supports rendering objects that `respond_to?` `:render_in`.
*Joel Hawksley*, *Natasha Umer*, *Aaron Patterson*, *Shawn Allen*, *Emily Plummer*, *Diana Mounter*, *John Hawthorn*, *Nathan Herald*, *Zaid Zawaideh*, *Zach Ahn*
* Fix `select_tag` so that it doesn't change `options` when `include_blank` is present.
*Younes SERRAJ*
2019-04-24 19:57:14 +00:00
Please check [6-0-stable](https://github.com/rails/rails/blob/6-0-stable/actionview/CHANGELOG.md) for previous changes.