FIX: Email Styles were evaluated out of order
`yield` puts the content in the template right away unless explicitly `capture`'d.
This commit is contained in:
parent
e8fb9d4066
commit
fd2d7ca992
|
@ -26,7 +26,7 @@ module EmailHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
def email_html_template
|
def email_html_template
|
||||||
EmailStyle.new.html.sub('%{email_content}', yield).html_safe
|
EmailStyle.new.html.sub('%{email_content}', capture { yield }).html_safe
|
||||||
end
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
|
@ -6,9 +6,10 @@ describe EmailStyle do
|
||||||
|
|
||||||
context "ERB evaluation" do
|
context "ERB evaluation" do
|
||||||
it "does not evaluate ERB outside of the email itself" do
|
it "does not evaluate ERB outside of the email itself" do
|
||||||
SiteSetting.email_custom_template = "<div>%{email_content}</div><%= (111 * 333) %>"
|
SiteSetting.email_custom_template = "<hello>%{email_content}</hello><%= (111 * 333) %>"
|
||||||
html = Email::Renderer.new(UserNotifications.signup(Fabricate(:user))).html
|
html = Email::Renderer.new(UserNotifications.signup(Fabricate(:user))).html
|
||||||
expect(html).not_to match("36963")
|
expect(html).not_to match("36963")
|
||||||
|
expect(html.starts_with?('<hello>')).to eq(true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue