Readme.md

This commit is contained in:
ErickSkrauch 2019-06-05 22:55:17 +03:00
parent 2528e1151b
commit 3f2146f45f
2 changed files with 42 additions and 14 deletions

View File

@ -1,21 +1,43 @@
This package allows rendering of React components into plain HTML to use it in emails. Each directory in `emails` dir corresponds to separate email template. Each email component will receive payload, passed from command line: # E-mails renderer
``` An internal tool used to render beautiful multilingual E-mail templates on the Accounts Ely.by project.
node cli --type=<email_dir_name> --payload=<json_encoded_in_base64> [--assetsHost=<scheme://host:port>] [--locale=be] The template engine uses React.js components, which are rendered into pure HTML with inlined styles, ready to be sent
to the mail.
Each directory in `emails` dir corresponds to separate email template. Each email component will receive payload, passed from command line:
## Development
First of all you need a copy of the repository. If you are planning to send a Pull Request, first
[create a fork](https://help.github.com/en/articles/fork-a-repo) of the repository. Then run the following commands:
```sh
# Clone your fork
git clone https://github.com/<your_username>/emails-renderer.git
# Switch to the project folder
cd emails-renderer
# Install dependencies
yarn install
``` ```
Try `php example.php` for demo. For the purpose of development, the project has a convenient development server and a toolbar that simplifies
templates debugging. To run it, use the `start` command:
# Email component structure ```sh
yarn start
```
* `index.js` — required. This file should export the main component, wich will receive payload. The server will be started at port `8080`. You can open it in your browser by going to `http://localhost:8080`.
* `fixtures.js` — an optional file exports hash `{featureId: payload, featureId2: payload}`. Use this to create data samples for testing in dev mode.
* `styles.js` — an optional file, that will hold style objects for email components to allow style inlining. ### Email component structure
* `index.ts` — required. This file should export the main component, which will receive payloads.
* `fixtures.ts` — an optional file exports hash `{featureId: payload, featureId2: payload}`.
Use this to create data samples for testing in dev mode.
* `styles.ts` — an optional file, that will hold styles objects for email components to allow styles inlining.
* `messages.intl.json` — an optional file, that exports hash with `{messageId: defaultMessage}` for `react-intl`. * `messages.intl.json` — an optional file, that exports hash with `{messageId: defaultMessage}` for `react-intl`.
# Available npm scripts ## Translating
* `npm start` — starts app in dev mode. Ely.by translation is done through the [Crowdin](https://crowdin.com) service.
* `npm run i18n` — collects translations and places in `src/i18n`. [Click here](https://translate.ely.by/project/elyby/invite) to participate in the translation of the project.
* `npm run build` — builds app for usage in `cli.js`.
* `npm run eslint` — lints source files.

View File

@ -1,13 +1,19 @@
{ {
"name": "@elyby/emails-renderer", "name": "@elyby/emails-renderer",
"version": "1.0.0", "version": "1.0.0",
"description": "", "description": "Tool for rendering multilingual templates sent to E-mail",
"main": "dist/app.js", "main": "dist/app.js",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/elyby/emails-renderer" "url": "https://github.com/elyby/emails-renderer"
}, },
"author": "SleepWalker <dev@udf.su>", "author": "SleepWalker <dev@udf.su>",
"maintainers": [
{
"name": "ErickSkrauch",
"email": "erickskrauch@ely.by"
}
],
"license": "Apache-2.0", "license": "Apache-2.0",
"bugs": { "bugs": {
"url": "https://github.com/elyby/emails-renderer/issues" "url": "https://github.com/elyby/emails-renderer/issues"