@vuemaildev/render
v0.1.0
Published
Transform Vue components into HTML email templates
Readme

Install
Install component from your command line.
With yarn
yarn add @vuemaildev/render -EWith npm
npm install @vuemaildev/render -Erender is also exported from @vuemaildev/vuemail, so you don't need to install this package if you already use it.
Getting started
Convert Vue components into a HTML string.
import { render } from '@vuemaildev/render';
import MyTemplate from '../components/MyTemplate.vue';
const html = await render(MyTemplate, { firstName: 'Jim' });render takes the component, its props, and some options, or a VNode and some options:
import { h } from 'vue';
const html = await render(h(MyTemplate, { firstName: 'Jim' }), { pretty: true });Options
pretty: formats the HTMLplainText: renders the plain text version of the email instead, customizable withhtmlToTextOptions, the options of html-to-textsetupApp: called with the Vue application before it renders, to install the plugins your email depends on, likevue-i18n
import { i18n } from '../i18n';
const text = await render(MyTemplate, { firstName: 'Jim' }, { plainText: true });
const localized = await render(
MyTemplate,
{ firstName: 'Jim' },
{ setupApp: (app) => app.use(i18n) },
);pretty and toPlainText are exported too, to format HTML or convert it into plain text.
Importing .vue files needs a build step that compiles them, like Nuxt with @vuemaildev/nuxt, Vite, or a bundler with a Vue plugin.
License
MIT License
