-
-
Notifications
You must be signed in to change notification settings - Fork 406
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deprecate {{with}} #445
Deprecate {{with}} #445
Conversation
Definitely in favor of migrating |
e6b2c97
to
6ca56d7
Compare
{{if-let}}
{{if-let}}
9be4de9
to
1f38a6d
Compare
text/0000-template.md
Outdated
|
||
This adds a litte API and documentation churn. | ||
|
||
## Alternatives |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's probably a very good reason for not doing it but just throwing this out there. Rather than increase the template API surface area could we enhance {{let}}
with the {{else}}
functionality?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@patocallaghan see the motivation section from the {{let}}
RFC:
While the conditional semantics of with are coherent with the other built-in helpers like each and if, users often find this unexpected. The fact that only the first positional parameter of with controls whether the block is rendered might also add to the confusion.
{{let}}
was purposefully designed to always render its block.
Deprecating
If the legacy What about |
Another benefit of composing {{#let}} and nested {{#if}} is that you could handle multiple params and react to different positional params being false-y in different ways in the UI 🤔 |
@tcjr Thanks, I'll add your suggestion to the list of alternatives. I crafted this RFC based on the comments in #316 (comment), it seemed to indicate the the core team were in favor of adding I actually prefer your example of combining
@Hemlok 👍
@rwjblue do you remember why there was support from the core team for adding |
Thinking about it more, I strongly agree that we should just deprecate |
@GavinJoyce Perhaps you could also alter the RFC to ensure public API exists so that and addon can implement |
{{if-let}}
@kellyselden here's a simple |
😜I got the naming wrong in the twiddle above, used EDIT: Oh, I actually got it right but thought that I got it wrong. The confusion point still stands |
I think that @tcjr / @Hemlok's intuition here is good. Manually writing out the nested version of if-let is easy enough, is not much longer than the shorthand tldr; 👍 on just making this a straight up deprecation RFC... |
text/0000-template.md
Outdated
|
||
We'll mentiton the deprecation in an Ember point release blog post. | ||
|
||
The deprecation message will link to good documentation which describe why `{{with}}` was deprecated and gives clear guidelines on how to migrate to using either `{{let}}` or `{{let}}` and `{{it}}` in combination. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should include the deprecation guide prose in this section directly. The deprecation guide entry will be linked to directly from the deprecation itself, and should show before/after examples for the various styles of {{with
usage.
text/0000-template.md
Outdated
|
||
## Unresolved questions | ||
|
||
This [comment](https://github.com/emberjs/rfcs/issues/316#issuecomment-449489686) seems to indicate some support for `{{if-let}}` from the core team. Perhaps there are some compelling reasons for add it that are not currently included in this RFC? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I personally like if-let
, but I think that this is just as easy to understand and doesn't rely on the reader to grok extra concepts....
Good discussion. I also favor deprecating |
I'd also like to suggest creating a linting rule (to aid folks who are not yet on newer versions with the deprecation but can use |
✅
@rwjblue for the same reasons as why we need to provide three options in the deprecation guide, I'm not sure that it will be possible to fully automate the migration from |
c641a6f
to
3dff63a
Compare
Well, there is a fully correct codemod that we could write. It would just look hideous in most cases when you didn't want the conditional behaviors. For example: {{#with (concat first ' ' last) as |name|}}
<h2>Hello, {{name}}!</h2>
{{/with}} Would have to be written as: {{#let (concat first ' ' last) as |name|}}
{{#if name}}
<h2>Hello, {{name}}!</h2>
{{/if}}
{{/let}} Even though we mostly know that we don't need that conditional. I think the codemod could actually have some pretty nice heuristics to be pretty close to what you would do by hand:
In addition, we could allow a flag to the codemod so that the person running it can opt in to "100% correctness, but super verbose" mode. The Ember.K codemod did essentially the same thing by requiring a flag to assume "chaining" or not (codemod docs here). Note: I think that we would need to test these heuristics on a number of apps, auditing the results. Just to make sure they are right a significant majority of the time... |
👍thanks, I've added a short note on adding a codemod to assist the migration |
We discussed this today at the framework core team meeting and decided to move this RFC into Final Comment Period |
We decided to accept this RFC at the framework core team meeting today. Thanks @GavinJoyce for working on this and everyone else for the discussion 🎉 |
@GavinJoyce do you mind renaming the file to match the RFC number? |
ee0cdd4
to
5364ea1
Compare
@chancancode updated, thanks |
closes #316
Rendered