RudManusachi
Recently I was reviewing the code and in the HEEX template I noticed something like:
<tr
id={"#item-#{Phoenix.Param.to_param(item)}"}
...
We all knew that item is the struct of the main resource we are dealing with on that view and I proposed to change the code to more simple and clear
<tr
id={"#item-#{item.id}"}
...
And overall I thought that we shouldn’t use Phoenix.Param.to_param/1 directly, not only in that context to fetch the param for the DOM element id but also anywhere else in our app code.. like leave it to the framework and treat it as “undocumented feature”.
However, co-worker pointed me to generated CoreComponents.table/1 where he got the idea from.
While, I see that in the generic CoreComponent we need to be able to come up with an id for arbitrary input, I still don’t think it’s a right function for the job.
WDYT?
Trending in Discussions
Other Trending Topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #ai
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming











Showing Posts 1 to 1- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
cmo
I guess it’s a way of moving the logic for deciding what will be [that part of] the DOM id to the struct itself. Then if you decide you want to use a different part of the struct for the DOM id, you only need to change it in one place.