Upgrade Docs for Phoenix.View to Phoenix.Template?

TL;DR: I’m upgrading an old middleware app from Phoenix 1.5 to 1.7 and I don’t speak Elixir. I’m looking for docs on migrating to Phoenix.Template.

So I read on this forum (Module Phoenix.View is not loaded and could not be found) that I can’t use Phoenix.View anymore. But now my web/views/contact_view.ex won’t compile since render_many/3 and render_one/3 no longer exist:

defmodule Redacted.ContactView do
  use Redacted.Web, :view

  def render("index.json", %{contacts: contacts}) do
    %{data: render_many(contacts, Redacted.ContactView, "contact.json")}

  def render("show.json", %{contact: contact}) do
    %{data: render_one(contact, Redacted.ContactView, "contact.json")}

  def render("contact.json", %{contact: contact}) do
    %{id: contact.id,
      email: String.slice(contact.email, 0..7),
      redacted_response_code: contact.redacted_response_code}

Somebody must have noted somewhere how to do this properly.

There’s no need to do that. Phoenix 1.7 will work just fine with Phoenix.View once you manually depend on the extracted package.


There is a guide for upgrading from 1.6 to 1.7.

1 Like

Exactly what I was looking for. Thank you.