use gjs in Linking Between Routes guide#2175
use gjs in Linking Between Routes guide#2175mcfiredrill wants to merge 4 commits intoember-learn:masterfrom
Conversation
Changed the templates from .hbs to .gjs, and added relevant imports. I didn't add the import or <template> when it looked like the example was only showing part of a template.
✅ Deploy Preview for ember-guides ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
| <h1>Latest Comments</h1> | ||
|
|
||
| <ul> | ||
| {{#each this.latestComments as |comment|}} |
There was a problem hiding this comment.
Does this.latestComments still work in route templates?
Shouldn't this be @controller.latestComments?
There was a problem hiding this comment.
very good point 👍 yes that would need to be @controller
There was a problem hiding this comment.
In that case, it probably applies to the other references to this as well so those also should be updated
There was a problem hiding this comment.
Yes, I was just going to suggest that you look at all the this. references in the newly converted gjs files. Some may come from the model and some from a controller.
Additionally, you will need to add import statements for everything you use in the template, like array and excerpt used below.
There was a problem hiding this comment.
well just to be clear here, until you explicitly added the file name this template wasn't technically wrong. You had "plausable denyability" that you were dealing with a component or something (although there was no backing class so the argument is very weak).
If you want to be 100% correct there should be a backing class that shows some latestComments and you can see what the template is referring to without having to guess that there is a controller that happens to have the latestComments field on it.
I hope all that makes sense
There was a problem hiding this comment.
Thanks for the feedback! I think I know what to do, I'm working on addressing this now then I'll ask for more feedback.
There was a problem hiding this comment.
Would it be better to write a backing class in the template or assume that latestComments came from a controller and just use @controller.latestComments ?
There was a problem hiding this comment.
I hate controllers, so I'm a fan of using the stateful component pattern instead of controller lol
There was a problem hiding this comment.
Yeah I guess we don't necessarily need to indrectly encourage controller use here
There was a problem hiding this comment.
Added a backing class version, although we had some discussion about longer term direction in the discord. https://discord.com/channels/480462759797063690/480777444203429888/1432054589661778003
mansona
left a comment
There was a problem hiding this comment.
thanks for this! can you update the language on the code blocks that you changed too?
|
@mansona done! |
Changed the templates from .hbs to .gjs, and added relevant imports.
I didn't add the import or when it looked like the example was only showing part of a template.