boriscy
Move template from a live component to html.heex template
Hello I would like to know if it’s possible to render the template on a .html.heex file for compoients inside liveview
I have this component
attr :group, Group
attr :user_id, :integer
def group(assigns) do
~H"""
<div class="group space-y-4" id={"group-#{@group.id}"}>
<div class="flex">
<div class="flex-1"></div>
<%= if Enum.count(@group.users) > 1 && @group.user_id == @user_id do %>
<button
phx-value-group_id={@group.id}
class="font-semibold text-accent icon"
phx-click="new-leader"
>
<.icon name="log-out" /> Leave Group
</button>
<% else %>
<button
data-confirm={gettext("Are you sure to leave the group?")}
phx-click="leave-group"
phx-value-group_id={@group.id}
class="font-semibold text-accent icon"
>
<.icon name="log-out" /> {gettext("Leave Group")}
</button>
<% end %>
</div>
<div class="text-xl">
{@group.name}
</div>
<div :for={{user, index} <- Enum.with_index(@group.users)} class="leading-3 flex gap-2">
<div class="text-secondary">
{index + 1}
</div>
<div>
<div>
{user.name}
</div>
<div class="text-sm text-secondary">
{user.email}
</div>
</div>
</div>
<div class="flex justify-between">
<.link patch={~p"/groups/#{@group.slug}"} class="text-primary font-semibold">
View All
</.link>
<%= if @user_id == @group.user_id do %>
<.link patch={~p"/groups/#{@group.slug}/add_members"} class="text-primary font-semibold">
{gettext("Add members")}
</.link>
<% end %>
</div>
</div>
"""
end
Can I move this to a group.html.heex and call from the group function, I had some suggestions from AI but did not work, one of them was
def group(assigns) do
render("group.html", assigns)
end
Most Liked
sodapopcan
Back before the robots took over we had documentation which is thankfully still lying around ![]()
5
Popular in Questions
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
Hi,
I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
New
After calling mix ecto.create I get this error:
17:00:32.162 [error] GenServer #PID<0.412.0> terminating
** (Postgrex.Error) FATAL...
New
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
Hi all,
Trying to get some more clarity over utc_datetime and naive_datetime for Ecto:
The documentation above suggests that while ...
New
Hi,
I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
Hi everyone,
I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
Other popular topics
Hello everyone,
I try to use an Javascript Event Handler in my root.html.leex file.
Therefore I created a function in the app.js file: ...
New
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service.
Currently when I de...
New
As promised, the first release candidate of Phoenix 1.3.0 is out! This release focuses on code generators with improved project structure...
New
After calling mix ecto.create I get this error:
17:00:32.162 [error] GenServer #PID<0.412.0> terminating
** (Postgrex.Error) FATAL...
New
Hi all,
I’ve just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage.
I’m trying to use Postgres...
New
This release brings a number of exciting features, including integration with the new Phoenix LiveDashboard and Phoenix LiveView. There h...
New
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
lets say i have a sample like
a = 20; b = 10;
if (a > b) do
{:ok, "a"}
end
if (a < b) do
{:ok, b}
end
if (a == b) do
{:ok, "equa...
New
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
Hi there,
I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance








