Skip to content

g-loot/react-email-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

React to html-template

Node script to server side render your react component into a html file locally. That can be used for example email building. Supports styled-components use and turns the styling into inline style.

Short example

const { ReactToHtml } = require(@g-loot/react-email-generator’);
/*
    Your imports for the components
*/
const TEMPLATES = [
  { fileName: ‘deposit-confirmation’, component: depositConfirmation },
  { fileName: ‘withdrawal-confirmation’, component: withdrawalConfirmation },
];
const options = {
  path: ‘templates’,
  styledComponents: true,
  emailTemplatePathName: ./email.html’,
  emailTemplateContentTag: %CONTENT%,
  emailTemplateStyleTag: %STYLE%,
  emailStylePathName: ./src/inlined.css’,
};
ReactToHtml(TEMPLATES, options);

Installation

Install this npm package: `npm i @g-loot/react-email-generator In your code:

const { ReactToHtml } = require(@g-loot/react-email-generator’);

Api

ReactToHtml(TEMPLATES, options)

* Features coming soon

templates :[{}] type default required description
fileName String “” Yes Name of the generate file
component String null Yes JS bundled React component
* componentStyle unknown null No Css file to be generated in head
options Type default required description
options.path String ./ Yes Target folder to save the generated files to
* options.styledComponents Bool false No
* options.emailTemplatePathName ??? ??? Provide your own html-template
* options.emailStylePathName ??? ??? Provide css files to be embedded in
* options.emailTemplateContentTag ??? %CONTENT% Identifier where to target the generated content.
* options.emailTemplateStyleTag ??? %STYLE% Identifier where to target the generated styles.

Extended example

Check out payments email repository

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages