Uh oh!
There was an error while loading. Please reload this page.
Add new basic helpers to Ember - #388
Conversation
| I propose to move to core at least: | ||
| - `eq` |
There was a problem hiding this comment.
If we want to maintain backwards compatibility it has to be ===. And even if compatibility wasn't a concern I'd still prefer triple equal
| - `add`, `subtract`, and other arithmetic operators. | ||
| - `{{#await promise as |value|}}` to render a block conditionally if a promise resolves or fails. | ||
| If there is interest in them, I advocate creating standalone RFCS for them. No newline at end of file |
There was a problem hiding this comment.
I agree, this RFC should be scoped to add the mentioned logic helpers, the others would need dedicated discussions.
Uh oh!
There was an error while loading. Please reload this page.
| - RFC PR: (leave this empty) | ||
| - Ember Issue: (leave this empty) | ||
| # (RFC title goes here) |
Uh oh!
There was an error while loading. Please reload this page.
| - `array` (there is an RFC for it: https://github.com/emberjs/rfcs/pull/318) | ||
| - `add`, `subtract`, and other arithmetic operators. | ||
| - `{{#await promise as |value|}}` to render a block conditionally if a promise resolves or fails. |
There was a problem hiding this comment.
Definitely useful IMHO, but should be a separate RFC.
There was a problem hiding this comment.
I agree 😄 👉 👉 👉 http://github.com/tildeio/ember-async-await-helper/
Uh oh!
There was an error while loading. Please reload this page.
webark
commented
Oct 13, 2018
just including the existing open RFC on this topic for cross reference, especially with regards to the “short circuiting”, abd why this needs to be done in core space... 😞 |
@webark I've expanded the information about short circuiting and how it can help making apps do less work. It would be nice if all helpers could short circuit by default, but that's just one of the four reasons to include those helpers into templating engine. I think it's still valuable even disregarding possible optimizations. Allowing all helpers to pull arguments as they use them would be a separate RFC. |
@cibernox thanks. and ya, i don't want to get into a “purity” debate. I (having never used ember truth helpers in many apps) always found that if i wanted to reach for one of these, more often then not it was due to a data structure that needed improvement, or that the chunk of template where i was wanting these warranted a new component itself. I will miss this “convention check”, but i feel the community has clearly spoken in favor of this, and there are clear benefits to including it in core. so i’m 👍 even if it’s with a 😞 |
Gaurav0
commented
Oct 15, 2018
Why not just make ember-truth-helpers part of the default blueprint? |
cibernox
commented
Oct 15, 2018
@Gaurav0 in the Alternatives section that possibility is discussed and I expose some arguments why I think this should be in the core. |
jonnii
commented
Oct 15, 2018
I also find myself by default installing ember-composable-helpers (https://github.com/DockYard/ember-composable-helpers) whenever starting a new ember applications. If there's an appetite for adding new helpers I'd also advocate for:
|
derekwsgray
commented
Oct 16, 2018
Totally agree. Have never used them, and found whenever someone on my team tried to add them it was inevitably !DRY and/or like you point out above. If they're going in, I'd much prefer default blueprint over core, so I could remove them. I do agree there are some decent use-cases I've been shown, but in general they require too much discipline to keep things from getting hairy. Or if there was an addition to the ember linter plugin... |
rwjblue
commented
Oct 16, 2018
FWIW, we do already have a similar concept in the |
cibernox
commented
Oct 16, 2018
@derekwsgray There is one particular use case that is very annoying to do without some basic logic helpers: You want to do some very simple check on every iteration. You can do it creating a component for the loop or wrapping your POJOs (to create a |
webark
commented
Oct 16, 2018
@cibernox and this is where this convo in something like discord would probably be better.. or if github did threads, but i think this can easily be an example of the later. You could argue something like But again.. this is something that is very subjective. In regards to the helpers, especially with the “short circuiting” of logic values, and the community desire, needs to be in core. You can still purposely not use them, but that can be a choice for an individual and/or a team. The community has clearly spoken in these RFC’s and the download numbers. |
Gaurav0
commented
Oct 16, 2018
One of the problems with adding stuff like this to core is what happens when a user defines a helper with the same name? Which one wins? How do we ensure that users update ember-truth-helpers to a version without "core" ones? |
@Gaurav0 From the RFC.
This update can happen in a patch as it's not a breaking change and anyone that has a floating version number will eventually get it. We might want to be smart and detect that if they are only using of the ported helpers (no About what wins, I think we should just do whatever we do today with built-in helpers like |
Gaurav0
commented
Oct 16, 2018
Doesn't this rely on the user updating to the new patch version of ember-truth-helpers? (Not guaranteed, I feel like I'm the only one at my company who ever tries to yarn upgrade.) |
@Gaurav0 correct, if they don't update and the user-defined helpers clover the default ones (which I don't know if it's the case) they wouldn't get the improvement. @rwjblue any insight on what is the best upgrade path? |
I think that would be a great idea. Of course, it would have to be a deprecation warning in the current 3.x cycle, and an error in 4.x actually. Too late for this situation. Probably needs its own RFC. |
derekwsgray
commented
Oct 16, 2018
Agree with the first part of @webark - the 'admin' example given is not great. The templates become harder to maintain against code changes as you say. Download numbers don't really sway my opinion (if they did, I'd be using a different framework, har har!). I respect the thought-leaders and proponents of best-practices. If the core ember team thinks this is a good idea, I respect that. |
I don't have any reason to think that the helpers in |
Panman82
commented
Apr 19, 2019
Related discussion here: #479 IMO, we should also add a |
In database systems there is an operation called I could see myself using a |
cibernox
commented
Apr 19, 2019
I think that a default helper could be nice in cases where false is a valid value. Regardless of that, we must resuscitate the discussion about truthyness. As far as I can remember that was the only controversy |
pzuraq
commented
Apr 19, 2019
I think a |
| - `gt` and `gte` | ||
| - `lt` and `lte` | ||
| Those helpers are very low lever and generally useful in both Ember and Glimmer. |
There was a problem hiding this comment.
| Those helpers are very low lever and generally useful in both Ember and Glimmer. | |
| Those helpers are very low level and generally useful in both Ember and Glimmer. |
mehulkar
commented
Jun 4, 2019
Apart from the truthiness discussion, adding more helpers blurs the line between Handlebars and Ember's flavor of Handlebars. I imagine as more added, it will be confusing to user just where to go for documentation on any part of the template they are looking at. An explicitly allowed list of template helpers (or template imports or strict mode #496) would help mitigate this problem, as it would be easier to see where these magic bits come from. Or we could decide this is a moot point, considering that package.json contains "ember-cli-htmlbars" and not "handlebars". |
FWIW, I'd like to see this move forward so that I can support optional dynamic tag name (once implemented) in a template only Glimmer Component from an addon without forcing another dep by using ember-truth-helpers. I realize I could just make that into an |
chriskrycho
commented
Oct 16, 2019
@Panman8201 I believe you could just use an inline (I'd also like this to move forward, just noting it's not blocking!) |
| Glimmer VM and passed to the helpers. This might include computationally expensive computed properties, | ||
| or hitting code paths that trigger network requests. | ||
| Implementing helpers like `and` or `or` at a lower lever would allow those helpers to be evaluated in |
There was a problem hiding this comment.
| Implementing helpers like `and` or `or` at a lower lever would allow those helpers to be evaluated in | |
| Implementing helpers like `and` or `or` at a lower level would allow those helpers to be evaluated in |
mcfiredrill
commented
Oct 17, 2019
Is something blocking this? It's unclear to me what the status is. |
I raised this in a few recent FW core meetings and it fell to @rwjblue and I to leave some of the feedback here. I'll work to get that done today or Friday. Edit: I swear I'm working on it! Got side tracked by publishing core notes and stuff but I am drafting. Edit: 2 mo. later it is obvious I dropped the ball. Talking with @pzuraq about getting it moving again. |
cagrimmett
commented
Dec 6, 2019
I'm a new Ember dev and we use @rwjblue's |
mixonic
commented
Dec 8, 2019
Framework core discussed this at the September F2F: https://github.com/emberjs/core-notes/blob/master/ember.js/2019-09/F2F_Ember_Core_Team_20190915.md#basic-helpers-rfc I'll try to summarize: @chancancode left a string of comments above, and he raised a few different points which we think remain unaddressed. That said, I think comments were a bit ad-hoc in their presentation and the F2F conversation may help clarify the over-arching concerns. My goal in raising the discussion at F2F was to try and find a path forward, and I think everyone is aligned on that goal. We all want to see some more convenience helpers added to the core framework. HBS v. JS truthiness, |
cibernox
commented
Dec 8, 2019
Great to see that this can finally move. My only concern with those helpers obeying handlebars' trutiness semantics is that it is different from what We'd have to plan to allow people to migrate without too much pain. I'm particularly worried about addons that use ember-truth-helpers, not so much about application code. I agree that splitting this RFC into three RFCs makes things easier. The one for the equality operators a the one for numerical comparisons are less controversial as they would be identical to those in Ember-truth-helpers and can be implemented quickly. I'll try to write all/some of those RFCs this week, but by any means if anyone wants to help, by all means, just call dibs on one of them in this thread. |
cibernox
commented
Dec 8, 2019
@mixonic I've open three separate RFCs as suggested, feel free to close this one now. |
rwjblue
commented
Dec 20, 2019
Thanks @cibernox! We discussed this in todays core team meeting and are moving this RFC into "FCP to Close" (in favor of the broken out / smaller RFCs). |
Any thoughts on where a |
locks
commented
Dec 20, 2019
@Panman82 I would submitted it on its own, as I think it would benefit from focused discussion! |
Rendered