Open mayel opened 3 years ago
i'm using it in a LiveView-Context in my project, but you have to go with a controller to inject the necessary data to the live-view-session, a bit hacky, but it works:
in the controller:
defmodule ThermostatController do
...
import Phoenix.LiveView.Controller
def show(conn, %{"id" => thermostat_id}) do
for_thesis=
%{ assigns:
Map.take(
conn.assigns,
~w(thesis_content thesis_dynamic_page thesis_editable thesis_page)a
)
|> Map.put(:thesis_editable, MyProject.ThesisAuth.page_is_editable?(conn))
}
|> Map.merge(Map.take(conn, ~w(request_path)a))
live_render(conn, ThermostatLive, session: %{
"thermostat_id" => id,
"current_user_id" => get_session(conn, :user_id),
"for_thesis" => for_thesis,
})
end
end
in the live-view-mount:
def mount(_params, session, socket) do
...
{:ok, assign( socket, :thesis_conn, session["for_thesis"] )}
end
in the .leex template:
<div phx-update="ignore">
<%= Thesis.View.thesis_editor(@thesis_conn) %>
</div>
<%= Thesis.View.content(@thesis_conn, "home-title", :text) do %>
My Text
<% end %>
Thanks @werkzeugh ! I got something similar to work, but indeed would be better to get proper integration specifically for LV.
Wondering if there are any plans to support using Thesis in LiveViews and LiveComponents? Thanks :)