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

Support for Phoenix 1.7 #7

Open
kyleboe opened this issue Mar 11, 2023 · 5 comments
Open

Support for Phoenix 1.7 #7

kyleboe opened this issue Mar 11, 2023 · 5 comments

Comments

@kyleboe
Copy link

kyleboe commented Mar 11, 2023

With Phoenix 1.7 replacing Phoenix.View with Phoenix.Component (see docs in :phoenix_view), bamboo_phoenix will need to be updated. This update will likely need to involve a few steps:

  1. Setting an upper limit on the currently specified phoenix version (involves a version release i.e. 1.0.1)
  2. Releasing a new version (i.e. 2.0.0) that either:
    a. Conforms to the updated usage of Phoenix.Component
    b. Includes :phoenix_view as a direct dependency so that Phoenix.View.render_to_string/3 can still be called

IMO 2a is the path that should be taken but I'd appreciate a maintainer's input before heading down a particular path.

@kyleboe
Copy link
Author

kyleboe commented Mar 22, 2023

It is also worth noting that there is some good debate going on here: swoosh/phoenix_swoosh#287

@icr4
Copy link

icr4 commented Mar 23, 2023

We have a working branch in our fork: https://github.com/populimited/bamboo_phoenix
Might be useful for a pull request

We've implemented support for Phoenix 1.7 and components as your 2.a point by conforming usage of Phoenix.Component

An example of how components should be implemented, using suffix to support both html and text formats.

defmodule PhoenixLayouts do
  use Phoenix.Component

  embed_templates "support/templates/phoenix_layout/*.html", suffix: "_html"
  embed_templates "support/templates/phoenix_layout/*.text", suffix: "_text"
end

defmodule EmailHTML do
  use Phoenix.Component

  embed_templates "support/templates/email/*.html", suffix: "_html"
  embed_templates "support/templates/email/*.text", suffix: "_text"

  def function_in_view do
    "function used in Bamboo.TemplateTest but needed because template is compiled"
  end
end

defmodule Email do
  use Bamboo.Phoenix, component: EmailHTML

  def text_and_html_email_with_layout do
    new_email()
    |> put_layout({PhoenixLayouts, :app})
    |> render(:text_and_html_email)
  end

  def html_email_with_layout do
    new_email()
    |> put_html_layout({PhoenixLayouts, "app_html"})
    |> render("html_email_html")
  end
end

@kyleboe
Copy link
Author

kyleboe commented Mar 24, 2023

That's be awesome to see your changes get merged in to this repo! I saw you opened a PR yesterday. Is there anyone from thoughtbot that has write access to this repo to get a PR like that merged in?

CC: @cpytel

@chrism2671
Copy link

@icr4 I see the PR was closed; was that on purpose?

@icr4
Copy link

icr4 commented Apr 26, 2023

@icr4 I see the PR was closed; was that on purpose?

Yes since it is not production ready yet, docs and backward compatibility should be further improved

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

3 participants