-
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
Expecting type String
for html parameter, getting Future<View>
#26
Comments
Hello, Same issue for me. I couldn't find any method to convert the view into a String value. Any news on that? Thanks, |
@joscdk What were you doing to make leaf work? |
@nickfarrant @goamigo try the following let content = try req.view().render("Emails/my-email", [
"name": "Bob"
])
return content.flatMap(to: Response.self) { content in
let contentString = String(data: content.data, encoding: .utf8)
let message = Mailgun.Message(
from: "[email protected]",
to: "[email protected]",
subject: "Newsletter",
text: "",
html: contentString ?? ""
)
let mailgun = try req.make(Mailgun.self)
return try mailgun.send(message, on: req)
} |
Here's how to do it with Vapor 4 and Mailgun 5.0.0: let content = req.view.render("Emails/my-email", [
"name": "Bob"
])
return content.flatMapThrowing { content in
let contentString = String(buffer: content.data)
let message = MailgunMessage(
from: "[email protected]",
to: "[email protected]",
subject: "Newsletter",
text: "",
html: contentString
)
return req.mailgun.send(message)
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
Great library, works really well.
The only issue I am having is using a Leaf template. The example code in the readme is generating an error in Xcode for me.
content
is of typeFuture<View>
, butMailgun.Message
expect aString
for thehtml
parameter.Is there a way around this or am I missing something obvious?
I have tried
html: "\(content)"
, but my Leaf template then generates:NIO.EventLoopFuture
in the email.Thanks in advance,
Nick
The text was updated successfully, but these errors were encountered: