-
-
Notifications
You must be signed in to change notification settings - Fork 31
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
Add leex/heex to projectionist #85
base: main
Are you sure you want to change the base?
Conversation
lua/elixir/projectionist/init.lua
Outdated
"", | ||
}, | ||
}, | ||
["lib/**/live/*_live.html.heex"] = { |
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 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.
It's unclear to me what the convention is at this time.
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.
Hm in this example the LiveView files themselves tend to be suffixed with _live.ex
as seen in the screenshot you posted with /live/home_live.ex
also seen at
https://github.com/fly-apps/live_beats/tree/master/lib/live_beats_web/live
And in order for Phoenix to use the .html.heex
file it should be named the same as the .ex
file but with the modified extension.
The most compelling example is seen in the official Phoenix LiveView documentation for Colocating Templates
For larger templates, you can place them in a file in the same directory and same name as the LiveView. For example, if the file above is placed at lib/my_app_web/live/thermostat_live.ex, you can also remove the
render/1
definition above and instead put the template code at lib/my_app_web/live/thermostat_live.html.heex.
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.
Hm in this example the liveview files themselves tend to be suffixed with _live.ex as seen In the screenshot you posted with /live/home_live.ex
also seen at
https://github.com/fly-apps/live_beats/tree/master/lib/live_beats_web/live
I'm referring to the template naming.
The most compelling example is seen in the official Phoneix LiveView documentation for Colocating Templates
For larger templates, you can place them in a file in the same directory and same name as the LiveView. For example, if the file above is placed at lib/my_app_web/live/thermostat_live.ex, you can also remove the render/1 definition above and instead put the template code at lib/my_app_web/live/thermostat_live.html.heex.
I think this might be an outdated example, as I think the current way to do the templates is just with components, using the embed_templates
macro
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.
If you'd like I could remove the _live
portion and it would effectively allow that to be optional since _live
is part of the filename if present.
Also, at the moment this is only covering the liveview heex/leex options, not the controller versions.
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.
makes me wonder if we should make the live view and live view test projections also drop that static convention.
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 could do that!
It would change generating a new file with the Elive blog_web/post
command to Elive blog_web/post_live
but make it more applicable to people who use different conventions so that seems like a worthy tradeoff.
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 think that makes sense. Thanks.
I probably won't get to testing this until next week.
Could you also (can be a separate PR) add some examples to the README?
79c28a4
to
20f59f8
Compare
20f59f8
to
50f38a4
Compare
I think you can
|
@zolrath let me know if you can get to this in the next week or so. if you can, i'll wait to cut the next release, but if not, i'll cut it and this can go in the next one |
This adds the
html.leex
/html.heex
files to projectionist.Only odd part on this is that we can't have multiple alternates so :A will jump to the test which will jump back to the .ex file.
Alternatives/Questions
.ex
file instead of the test.["<div>", "", "</div>"]
template or just leave it blank?Usage
Due to the ambiguity these would mostly be used via :Eleex and :Eheex to switch to the file or create it if it does not exist.