add dev email preview route

This commit is contained in:
shibao 2022-02-17 21:47:37 -05:00
parent 776d8a0250
commit 8cb8294ffd
3 changed files with 28 additions and 0 deletions

View File

@ -0,0 +1,23 @@
defmodule CanneryWeb.EmailController do
@moduledoc """
A dev controller used to develop on emails
"""
use CanneryWeb, :controller
alias Cannery.Accounts.User
plug :put_layout, {CanneryWeb.LayoutView, :email}
@sample_assigns %{
email: %{subject: "Example subject"},
url: "https://cannery.bubbletea.dev/sample_url",
user: %User{email: "sample@email.com"}
}
@doc """
Debug route used to preview emails
"""
def preview(conn, %{"id" => template}) do
render(conn, "#{template |> to_string()}.html", @sample_assigns)
end
end

View File

@ -114,5 +114,9 @@ defmodule CanneryWeb.Router do
forward "/mailbox", Plug.Swoosh.MailboxPreview
end
scope "/dev" do
get "/preview/:id", CanneryWeb.EmailController, :preview
end
end
end

View File

@ -0,0 +1 @@
<%= @inner_content %>