1. Install dependencies
Install package from your command line.render is also published on its own as @vuemaildev/render, for when you only need the render utility.
Both packages export the same functions.2. Create an email using Vue
Start by building your email template in a.vue file.
email.vue
3. Convert to HTML
Import an existing Vue component and convert into a HTML string.You can use the
pretty function to beautify the output.Passing props
The second argument ofrender are the props of the email:
render also takes a VNode, created with h(), in which case the options are its second argument:
If a component throws while the email renders, including from an async
setup(), render rejects
with that error instead of returning an incomplete email.4. Convert to Plain Text
Plain text versions of emails are important because they ensure that the message can be read by the recipient even if they are unable to view the HTML version of the email. This is important because not all email clients and devices can display HTML email, and some recipients may have chosen to disable HTML email for security or accessibility reasons. Here’s how to convert a Vue component into plain text.plainText option does the same in a single call: await render(MyTemplate, {}, { plainText: true }).
Exclude content from plain-text output
Adddata-skip-in-text="true" to an element to exclude the element and its contents when using toPlainText(). This does not exclude the element from the HTML output.
Installing Vue plugins
render renders each email with a new Vue application. To install plugins your emails depend on, like
vue-i18n, pass a setupApp function, which receives that
application before it renders:
Options
boolean
Beautify HTML output
boolean
Generate plain text version
boolean
With
plainText, converts to plain text with an in-house formatter instead of html-to-text,
which doesn’t take htmlToTextOptions. Experimental.(app: App) => unknown
Called with the Vue application used for rendering, before it renders. Use it to install plugins,
like
vue-i18n.