How to use the mjml-react.render function in mjml-react

To help you get started, we’ve selected a few mjml-react examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github goldenshun / nextmail / lib / renderEmail.js View on Github external
async function renderEmail(name, props, { pathPrefix } = {}) {
  const thePathPrefix = pathPrefix || root;
  const Email = require(`${thePathPrefix}/.nextmail/${name}`).default;
  const { html } = render(Email(props));
  const text = htmlToText.fromString(html);

  return { html, text };
}
github goldenshun / nextmail / lib / Renderer.js View on Github external
const initialProps = typeof Template.getInitialProps === 'function'
      ? await Template.getInitialProps({ payload })
      : {};
    debug('initialProps: %o', initialProps);

    const props = Object.assign({}, payload, initialProps);
    debug('props: %o', props);

    const subject = typeof Template.getSubject === 'function'
      ? await Template.getSubject({ payload, props })
      : null;

    debug('subject: %s', subject);

    const { html } = render(Template(props));
    const text = htmlToText.fromString(html);

    return { html, subject, text };
  }
}

mjml-react

<img src="https://cdn.worldvectorlogo.com/logos/mjml-by-mailjet.svg" height="64"/> &middot; <img src="https://cdn.worldvectorlogo.com/logos/react.svg" width="64" height="64"/>

MIT
Latest version published 2 years ago

Package Health Score

59 / 100
Full package analysis

Popular mjml-react functions

Similar packages