[DOCS] add examples for yield
What changed
Added in more examples for yield
https://api.emberjs.com/ember/4.4/classes/Ember.Templates.helpers/methods/yield?anchor=yield
- [x] add yield with hash helper
- [x] add yield with hash and component helper
- [x] add yield for multiple block parameters
- [x] add yield with hash and component helper with attributes and args
Rationale
Coming from React, yield is a bit of a weird concept. Having more examples of how to use yield with hash and component helpers will help people making components who are coming from another framework and are trying to make more composable components with a small API footprint (more "HTML" like components)
Partly inspired by: https://www.youtube.com/watch?v=uTFxv0kReYk&list=PLRtznLaEWGuf87iG3LZarzyMb24JCX9Pv
- wanted to show that you could use @arguments and attributes
- wanted to show that you could move components around
Question: I can't seem to re-request review or resolve comments? - but if anyone wants to (re) take a look, that would be appreciated!
Question: Should (I also) do a comparison with let versus yield here?
let with hash + component helper: have to render the components in the same file yield with hash + component helper: allows the consumer of the component render how they want with args and attributes
Hi Nicole, thanks again for your work on this!
I recommend that the framework team does a final review & merge this, and any additional improvements can be a followup PR.
I discussed the issue of Guides vs API docs as the home for this with locks. After that conversation, I think eventually it would be good to show examples like this in a cookbook or “advanced” section of the guides. If anyone wants to give that a try, in addition to this PR moving forward, that’s welcome! We have room for more commentary there.
Thank you! This seems reasonable to me. (and, I should add, clearly and well written!)