Skip to content

Commit

Permalink
Separate conversation template into .leex file
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentvanbush committed Nov 1, 2020
1 parent 183db92 commit 46407cb
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 23 deletions.
25 changes: 2 additions & 23 deletions lib/curious_messenger_web/live/conversation_live.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,10 @@ defmodule CuriousMessengerWeb.ConversationLive do
use Phoenix.HTML

alias CuriousMessenger.{Auth, Chat, Repo}
alias CuriousMessengerWeb.ConversationView

def render(assigns) do
~L"""
<div>
<b>User name:</b> <%= @user.nickname %>
</div>
<div>
<b>Conversation title:</b> <%= @conversation.title %>
</div>
<div>
<%= f = form_for :message, "#", [phx_submit: "send_message"] %>
<%= label f, :content %>
<%= text_input f, :content %>
<%= submit "Send" %>
</form>
</div>
<div>
<b>Messages:</b>
<%= for message <- @messages do %>
<div>
<b><%= message.user.nickname %></b>: <%= message.content %>
</div>
<% end %>
</div>
"""
ConversationView.render("show.html", assigns)
end

def mount(assigns, socket) do
Expand Down
21 changes: 21 additions & 0 deletions lib/curious_messenger_web/templates/conversation/show.html.leex
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<div>
<b>User name:</b> <%= @user.nickname %>
</div>
<div>
<b>Conversation title:</b> <%= @conversation.title %>
</div>
<div>
<%= f = form_for :message, "#", [phx_submit: "send_message"] %>
<%= label f, :content %>
<%= text_input f, :content %>
<%= submit "Send" %>
</form>
</div>
<div>
<b>Messages:</b>
<%= for message <- @messages do %>
<div>
<b><%= message.user.nickname %></b>: <%= message.content %>
</div>
<% end %>
</div>
3 changes: 3 additions & 0 deletions lib/curious_messenger_web/views/conversation_view.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
defmodule CuriousMessengerWeb.ConversationView do
use CuriousMessengerWeb, :view
end

0 comments on commit 46407cb

Please sign in to comment.