Building the UI Itself

Phoenix, unfortunately, does not have a built-in concept of shared templates or views, so we're going to have to make one ourself! We'll start off by creating a new view called VocialWeb.SharedView. Create lib/vocial_web/views/shared_view.ex and give it the base view code:

defmodule VocialWeb.SharedView do  use VocialWeb, :viewend

Next, create a new directory under lib/vocial_web/templates called shared, and in there we're going to create _chat.html.eex. Then, in lib/vocial_web/templates/shared/_chat.html.eex, we'll just give it some dummy code:

<div>  <h1>CHAT</h1></div>

Finally, we can open up lib/vocial_web/templates/poll/show.html.eex and add the following line to the bottom of our template:

<%= render(VocialWeb.SharedView, ...

Get Phoenix Web Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.