What's the cut-off code at 6:48 in "Build a real-time Twitter clone"

Trying to reconstruct the post_component.ex at this point in the walk-thru.

I tried to piece together the rest of the lines at live_patch and link but failed. This is what I have:

defmodule ChirpWeb.PostLive.PostComponent do
  use ChirpWeb, :live_component

  def render(assigns) do
    ~L"""
    <div id="post"-<%= @post.id %>" class="post">
      <div class="row">
        <div class="column column-10">
          <div class="post-avatar"></div>
        </div>
        <div class="column column-90 post-body">
          <b>@<%= @post.username %></b>
          <br />
          <%= @post.body %>
        </div>
      </div>

      <div class="row">
        <div class="column">
          <i class="far f-heart"></i> <%= @post.likes_count %>
        </div>
        <div class="column">
          <i clas="far fa-retweet"></i> <%= @post.reposts_count %>
        </div>
        <div class="column">
          <%= live_patch to: Routes.post_index_path(@socket, :edit, @post.id) %>
            <i class="far fa-edit"></i>
          <% end %>
          <%= link to: "#", phx_click: "delete", phx_value_id: @post.id, data: [confirm: "Are you sure?"] %>
            <i class="far fa-trash-alt"></i>
          <% end %>
        </div>
      </div>
    </div>
    """
  end
end

What I get is:

You are missing a do in the call to live_patch (and also later in link).

2 Likes

I had encountered the same issue: The below code worked for me after @lucaong suggestion.

def render(assigns) do
        ~L"""
        <div id="post-<%= @post.id %>" class="post">
            <div class="row">
                <div class="column column-10">
                    <div class="post-avatar"></div>
                </div>
                <div class="column column-90 post-body">
                    <b>@<%= @post.username %></b>
                    <br />
                    <%= @post.body %>
                </div>
            </div>
            <div class="row">
                <div class="column">
                    <i class="far fa-heart"></i> <%= @post.likes_count %>
                </div>
                <div class="column">
                    <i class="far fa-retweet"></i> <%= @post.reposts_count %>
                </div>
                <div class="column">
                    <%= live_patch to: Routes.post_index_path(@socket, :edit, @post.id) do %>
                        <i class="far fa-edit"></i>
                    <% end %>
                    <%= link to: "#", phx_click: "delete", phx_value_id: @post.id, data: [confirm: "Are you sure?"] do %>
                        <i class="far fa-trash-alt"></i>
                    <% end %>
                </div>
            </div>
        </div>
        """
2 Likes