Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to migrate from pow_mailer_layout to pow_mailer_layouts #727

Closed
nikcorg opened this issue Mar 14, 2024 · 1 comment
Closed

How to migrate from pow_mailer_layout to pow_mailer_layouts #727

nikcorg opened this issue Mar 14, 2024 · 1 comment

Comments

@nikcorg
Copy link

nikcorg commented Mar 14, 2024

Hello!

I spotted a warning mentioning that pow_mailer_layout had been deprecated and it is indeed even in the changelog.

Are there migration instructions anywhere to moving from the old to the new?

@danschultzer
Copy link
Collaborator

Yeah, I should have added more to that changelog. Updated both the changelog and the warning with #730, thanks!

This was part of moving towards Phoenix 1.7 syntax changes, so it follows the same rules. Instead of:

put_private(conn, :pow_mailer_layout, {MyAppWeb.LayoutView, :email})

You would do something like:

put_private(conn, :pow_mailer_layouts, html: {MyAppWeb.Layouts, :email}, text: false

# If you use layout for text
put_private(conn, :pow_mailer_layouts, html: {MyAppWeb.Layouts, :email}, text: {MyAppWeb.Layouts, :email_text}

The Layouts module may look something like:

defmodule MyAppWeb.Layouts do
  @moduledoc false
  use MyAppWeb, :html

  embed_templates "layouts/*.html"

  # If you use layout for text
  embed_templates "layouts/*.text", suffix: "_text"
end

You can see how text email uses a suffix to avoid conflicts with the embed_templates. This is so we can use the Phoenix HTML helpers. You could also split it in two separate modules (one for HTML emails and one for text emails).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants