0.2.0 • Published 5 months ago
@maily-to/render v0.2.0
Install
Install @maily-to/render
from your command line.
pnpm add @maily-to/render
Getting started
Convert React components into a HTML string.
import { render } from '@maily-to/render';
const html = await render({
type: 'doc',
content: [
{
type: 'paragraph',
content: [
{
type: 'text',
text: 'Hello World!',
},
],
},
],
});
Variables
You can replace variables in the content.
import { Maily } from '@maily-to/render';
const maily = new Maily({
type: 'doc',
content: [
{
type: 'paragraph',
attrs: { textAlign: 'left' },
content: [
{
type: 'variable',
attrs: {
id: 'currentDate',
fallback: 'now',
showIfKey: null,
},
},
],
},
],
});
maily.setVariableValue('currentDate', new Date().toISOString());
const html = await maily.render();
Payloads
Payload values are used for the Repeat
and Show If
blocks.
// (Omitted repeated imports)
const maily = new Maily({
type: 'doc',
content: [
{
type: 'repeat',
attrs: { each: 'items', showIfKey: null },
content: [
{
type: 'paragraph',
attrs: { textAlign: 'left' },
content: [{ type: 'text', text: 'Hello' }],
},
],
},
],
});
maily.setPayloadValue('items', ['Alice', 'Bob', 'Charlie']);
const html = await maily.render();
Contributions
Feel free to submit pull requests, create issues, or spread the word.
License
MIT © Arik Chakma
0.0.15
10 months ago
0.0.16
10 months ago
0.0.17
10 months ago
0.0.18
9 months ago
0.0.19
9 months ago
0.0.13
11 months ago
0.0.14
10 months ago
0.1.0
8 months ago
0.1.2
7 months ago
0.2.0
5 months ago
0.1.1
8 months ago
0.1.4
7 months ago
0.1.3
7 months ago
0.1.5
6 months ago
0.0.11
1 year ago
0.0.12
1 year ago
0.0.10
1 year ago
0.0.9
1 year ago
0.0.8
2 years ago
0.0.7
2 years ago
0.0.6
2 years ago
0.0.5
2 years ago
0.0.4
2 years ago
0.0.3
2 years ago
0.0.2
2 years ago
0.0.1
2 years ago