-
-
Notifications
You must be signed in to change notification settings - Fork 407
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #690 from emberjs/deprecate-attrs-in-templates
- Loading branch information
Showing
1 changed file
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
--- | ||
Stage: Accepted | ||
Start Date: 2020-12-22 | ||
Release Date: Unreleased | ||
Release Versions: | ||
ember-source: vX.Y.Z | ||
ember-data: vX.Y.Z | ||
Relevant Team(s): Ember.js | ||
RFC PR: https://github.com/emberjs/rfcs/pull/690 | ||
--- | ||
|
||
# Deprecate using `{{attrs}}` in templates | ||
|
||
## Summary | ||
|
||
The `{{attrs}}` object in templates is an alternative way for users to reference | ||
named arguments directly in a template. | ||
|
||
```hbs | ||
{{attrs.foo}} | ||
{{! is equivalent to }} | ||
{{@foo}} | ||
``` | ||
|
||
It was a legacy API that existed prior to named arguments being introduced in | ||
Ember, and has continued to be supported via a template transform for some time. | ||
This RFC proposes that we deprecate this functionality in favor of directly | ||
using named arguments. | ||
|
||
## Motivation | ||
|
||
The `{{attrs}}` syntax was from a previous iteration of the concepts that | ||
eventually became named argument syntax. Now that named arguments exist in the | ||
framework, and are considered the best practice, there is no reason to continue | ||
supporting this syntax. | ||
|
||
## Transition Path | ||
|
||
Users who currently rely on referencing `{{attrs}}` can convert their references | ||
to named arguments. This should be highly codemoddable, and we will attempt to | ||
make a codemod to help out with the transition. | ||
|
||
## How We Teach This | ||
|
||
### Deprecation Guide | ||
|
||
The `{{attrs}}` object was an alternative way to reference named arguments in | ||
templates that was introduced prior to named arguments syntax being finalized. | ||
References to properties on `{{attrs}}` can be converted directly to named | ||
argument syntax. | ||
|
||
Before: | ||
|
||
```hbs | ||
{{attrs.foo}} | ||
{{this.attrs.foo.bar}} | ||
{{deeply (nested attrs.foobar.baz)}} | ||
``` | ||
|
||
After: | ||
|
||
```hbs | ||
{{@foo}} | ||
{{@foo.bar}} | ||
{{deeply (nested @foobar.baz)}} | ||
``` | ||
|
||
## Drawbacks | ||
|
||
- None |