2
votes

In a regular controller/view, let's say I have AppWeb.ItemView, and AppWeb.ItemController. Let's say I have two different indexes, :index and :index_funky. If I wanted to render index.html.eex for the :index_funky view, I could create a render function in AppWeb.ItemView with the head render("index_funky.html", assigns) and inside that do a render("index.html", assigns). That works fine: I would get the data from AppWeb.ItemController.index_funky using the template from AppWeb.ItemController.index.

How can I do the same with a LiveView? If I have AppWeb.ItemLive.Index and AppWeb.ItemLive.IndexFunky, how can I render index.html.leex for AppWeb.ItemLive.IndexFunky?

1

1 Answers

2
votes

Not sure about your reason behind it, but I would encourage you to look at handle_params if it helps your case.

Now, for your case, you can delegate to an existing view like this

defmodule AppWeb.ItemLive.IndexFunky do
  use AppWeb, :live_view

  def render(assigns) do
    Phoenix.View.render(AppWeb.ItemLive.Index, "index.html", assigns)
  end
end 

Documentation