From 46407cb385197513b7ee489128236defe24cfeee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Buszkiewicz?= Date: Tue, 12 Nov 2019 21:21:43 +0100 Subject: [PATCH] Separate conversation template into .leex file --- .../live/conversation_live.ex | 25 ++----------------- .../templates/conversation/show.html.leex | 21 ++++++++++++++++ .../views/conversation_view.ex | 3 +++ 3 files changed, 26 insertions(+), 23 deletions(-) create mode 100644 lib/curious_messenger_web/templates/conversation/show.html.leex create mode 100644 lib/curious_messenger_web/views/conversation_view.ex diff --git a/lib/curious_messenger_web/live/conversation_live.ex b/lib/curious_messenger_web/live/conversation_live.ex index 4882aaf..b462d20 100644 --- a/lib/curious_messenger_web/live/conversation_live.ex +++ b/lib/curious_messenger_web/live/conversation_live.ex @@ -5,31 +5,10 @@ defmodule CuriousMessengerWeb.ConversationLive do use Phoenix.HTML alias CuriousMessenger.{Auth, Chat, Repo} + alias CuriousMessengerWeb.ConversationView def render(assigns) do - ~L""" -
- User name: <%= @user.nickname %> -
-
- Conversation title: <%= @conversation.title %> -
-
- <%= f = form_for :message, "#", [phx_submit: "send_message"] %> - <%= label f, :content %> - <%= text_input f, :content %> - <%= submit "Send" %> - -
-
- Messages: - <%= for message <- @messages do %> -
- <%= message.user.nickname %>: <%= message.content %> -
- <% end %> -
- """ + ConversationView.render("show.html", assigns) end def mount(assigns, socket) do diff --git a/lib/curious_messenger_web/templates/conversation/show.html.leex b/lib/curious_messenger_web/templates/conversation/show.html.leex new file mode 100644 index 0000000..85ce9d2 --- /dev/null +++ b/lib/curious_messenger_web/templates/conversation/show.html.leex @@ -0,0 +1,21 @@ +
+ User name: <%= @user.nickname %> +
+
+ Conversation title: <%= @conversation.title %> +
+
+ <%= f = form_for :message, "#", [phx_submit: "send_message"] %> + <%= label f, :content %> + <%= text_input f, :content %> + <%= submit "Send" %> + +
+
+ Messages: + <%= for message <- @messages do %> +
+ <%= message.user.nickname %>: <%= message.content %> +
+ <% end %> +
\ No newline at end of file diff --git a/lib/curious_messenger_web/views/conversation_view.ex b/lib/curious_messenger_web/views/conversation_view.ex new file mode 100644 index 0000000..5565c6e --- /dev/null +++ b/lib/curious_messenger_web/views/conversation_view.ex @@ -0,0 +1,3 @@ +defmodule CuriousMessengerWeb.ConversationView do + use CuriousMessengerWeb, :view +end