This is a fork of usewaypoint/email-builder-js with some modifications to allow for the types of emails we need to send at Trophy.
npm install @trophy/email-builder-js
import { EmailBuilder } from '@trophy/email-builder-js';
import { renderToStaticMarkup, TReaderDocument } from '@trophyso/email-builder-js';
const document: TReaderDocument = {
// Document content here
};
const html = renderToStaticMarkup(document, { rootBlockId: 'root' });
This package is written in TypeScript. npm install
will install all packages, including in nested
folders (each block is its own package, with its own package.json
).
All code is tested using jest. To run the tests, run:
npm test
After making changes to a component, if you've verified that it looks correct, simply delete the
__snapshots__
folder and run the tests again to update the snapshots.
To build the package, tick the version number and run:
npm run build && npm publish
For local development with the Trophy app, you can link the package to the Trophy app by setting the dependency to the local repo from the Trophy app:
{
"dependencies": {
"@trophy/email-builder": "file:../email-builder-js"
}
}
Then run:
npm install
This will symlink this email-builder-js dist
folder to the node_modules
folder of the Trophy
app, so you only need to npm run build
to see the changes immediately reflected in the Trophy app.
Packages are built automatically when pushed to the main
branch.