forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request quarkusio#7733 from FroMage/qute-enhancements
Qute enhancements
- Loading branch information
Showing
48 changed files
with
1,122 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -230,6 +230,39 @@ When you want to reference your attachment, for instance in the `src` attribute, | |
|
||
It's also possible to inject a mail template, where the message body is created automatically using link:qute[Qute templates]. | ||
|
||
[source, java] | ||
---- | ||
@Path("") | ||
public class MailingResource { | ||
@CheckedTemplate | ||
class Templates { | ||
public static native MailTemplateInstance hello(String name); <1> | ||
} | ||
@GET | ||
@Path("/mail") | ||
public CompletionStage<Response> send() { | ||
// the template looks like: Hello {name}! <2> | ||
return Templates.hello("John") | ||
.to("[email protected]") <3> | ||
.subject("Hello from Qute template") | ||
.send() <4> | ||
.subscribeAsCompletionStage() | ||
.thenApply(x -> Response.accepted().build()); | ||
} | ||
} | ||
---- | ||
<1> By convention, the enclosing class name and method names are used to locate the template. In this particular case, | ||
we will use the `MailingResource/hello.html` and `MailingResource/hello.txt` templates to create the message body. | ||
<2> Set the data used in the template. | ||
<3> Create a mail template instance and set the recipient. | ||
<4> `MailTemplate.send()` triggers the rendering and, once finished, sends the e-mail via a `Mailer` instance. | ||
|
||
TIP: Injected mail templates are validated during build. If there is no matching template in `src/main/resources/templates` the build fails. | ||
|
||
You can also do this without type-safe templates: | ||
|
||
[source, java] | ||
---- | ||
@Inject | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.