-
Notifications
You must be signed in to change notification settings - Fork 31
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
phoenix 1.6-rc0 - render_body with atom do nothing #208
Comments
Hi, could you try |
There should be no breaking change and should work with phoenix 1.6 |
I upgraded also phoenix_swoosh with: |
Hi @romaluca I'm going to need more info to debug that. Testing with a toy project shows that it works properly with atoms. Could you setup a minimal reproducible example? What I got:
defmodule TestSwoosh.Something do
use Phoenix.Swoosh, view: TestSwoosh.MyView
def hi do
new()
|> subject("what")
|> to("test@test.com")
|> from("test@test.com")
|> render_body(:hi, name: "world")
end
end
defmodule TestSwoosh.MyView do
use Phoenix.View, root: "lib/test_swoosh/templates"
end
<h1>Hello, <%= @name %></h1>
iex(1)> TestSwoosh.Something.hi
%Swoosh.Email{
assigns: %{layout: false, name: "world"},
attachments: [],
bcc: [],
cc: [],
from: {"", "test@test.com"},
headers: %{},
html_body: "<h1>Hello, world</h1>\n",
private: %{
phoenix_layout: false,
phoenix_template: "hi.text",
phoenix_view: TestSwoosh.MyView
},
provider_options: %{},
reply_to: nil,
subject: "what",
text_body: "Hello, world\r\n",
to: [{"", "test@test.com"}]
} |
|
i found the cause is the layout. I have this: and these files for the common layout:
If i remove this from the code it works: |
I tried the send with iex and there is an error: |
Has this always been |
I added layout and still works. I did get an error, but a different one, if I named it
defmodule TestSwoosh.Something do
use Phoenix.Swoosh, view: TestSwoosh.MyView, layout: {TestSwoosh.LayoutView, :email}
def hi do
new()
|> subject("what")
|> to("test@test.com")
|> from("test@test.com")
|> render_body(:hi, name: "world")
end
end
defmodule TestSwoosh.LayoutView do
use Phoenix.View, root: "lib/test_swoosh/templates"
end
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body>
<%= @inner_content %>
</body>
</html>
iex(8)> TestSwoosh.Something.hi
%Swoosh.Email{
assigns: %{layout: {TestSwoosh.LayoutView, "email.text"}, name: "world"},
attachments: [],
bcc: [],
cc: [],
from: {"", "test@test.com"},
headers: %{},
html_body: "<!DOCTYPE html>\n<html lang=\"en\">\n <head>\n <meta charset=\"UTF-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n <title>Document</title>\n </head>\n <body>\n<h1>Hello, world</h1>\n\n </body>\n</html>\n",
private: %{
phoenix_layout: {TestSwoosh.LayoutView, :email},
phoenix_template: "hi.text",
phoenix_view: TestSwoosh.MyView
},
provider_options: %{},
reply_to: nil,
subject: "what",
text_body: "TEST Hello, world\r\n\n",
to: [{"", "test@test.com"}]
} |
Excuse me, in my post i wanted write |
Did you manage to figure out what the issue is? |
Yes, i used the same LayoutView for web pages and email |
Interesting. Thanks for the reply. |
Hi, i upgraded my webapp to phoenix 1.6-rc0 and now the tests of mail sending are failing
I noticed that the cause is render body with atom parameter (:registration_confirm) do nothing. No error is reported:
new()
|> to({user.name, user.email})
|> from(@from)
|> subject(subject)
|> render_body(:registration_confirm, %{username: user.name, url: url, subject: subject})
But if i change this in:
new()
|> to({user.name, user.email})
|> from(@from)
|> subject(subject)
|> render_body("registration_confirm.html", %{username: user.name, url: url, subject: subject})
It works. In my app there are the "registration_confirm.html.eex" and "registration_confirm.text.eex"
Is not possible using atom any more?
The text was updated successfully, but these errors were encountered: