Skip to content

Commit

Permalink
Merge pull request #690 from emberjs/deprecate-attrs-in-templates
Browse files Browse the repository at this point in the history
  • Loading branch information
rwjblue committed Jan 15, 2021
2 parents 94cb144 + 1972114 commit 3254432
Showing 1 changed file with 71 additions and 0 deletions.
71 changes: 71 additions & 0 deletions text/0690-deprecate-attrs-in-templates.md
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

0 comments on commit 3254432

Please sign in to comment.