- Start Date: 2019-02-13
- Relevant Teams: Ember.js, Learning
- RFC PR: #445
- Tracking: (leave this empty)
The {{with}}
helper has always had slightly confusing conditional semantics, this was one of the motivators for introducing the easier to understand {{let}}
helper. Now that {{let}}
exists, the remaining use case for using {{with}}
is for its unique conditional semantics. The name {{with}}
doesn't accurately represent the helpers behavior, we should rename it to {{if-let}}
.
The difference between {{let}}
and {{with}}
is with how they handle conditional arguments. The {{let}}
helper's block content is always rendered, regardless of its parameters. In contrast, {{with}}
only renders its main block when the first position parameter is truthy. For example:
Will render "[Alex] is truthy".
Will render "The first positional param was falsy".
As the naming of {{with}}
doesn't give any indication of its behavior, we should deprecate it and introducing the better named {{if-let}}
helper. Doing do will make Ember easier to learn and use.
We'll create a new {{if-let}}
helper which will have the same behavior to the current {{with}}
helper.
We'll create an AST transform in packages/ember-template-compiler
which will emit a deprecation warning for all uses of {{with}}
. The deprecation warning will be something like:
Using `{{with}}` is deprecated, please use the `{{let}}` or `{{if-let}}` helpers instead.
This new deprecation warning should link to some docs which clearly describe when you should use {{let}}
and when you should use {{let-if}}
.
We'll add {{if-let}}
documentation to the Ember.Templates.helpers
API docs. The new documentation should make the unique use cases of {{if-let}}
clear.
We'll mentiton the new {{if-let}}
helper in an Ember point release blog post.
The deprecation message will link to good docs which describe why {{with}}
was deprecated and give clear guidlines on how to migrate to using either {{let}}
or {{if-let}}
.
This adds a litte API and documentation churn.
We could leave {{with}}
as is. I don't believe that this is a good option as the name {{with}}
is far from ideal.
We could deprecate {{with}}
and introduce {{if-let}}
in an addon instead of Ember core.
None