@solid-email/render 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +82 -0
- package/dist/browser/index.cjs +489 -116
- package/dist/browser/index.d.cts +27 -16
- package/dist/browser/index.d.cts.map +1 -1
- package/dist/browser/index.d.mts +27 -16
- package/dist/browser/index.d.mts.map +1 -1
- package/dist/browser/index.mjs +489 -116
- package/dist/browser/index.mjs.map +1 -1
- package/dist/edge/index.cjs +489 -116
- package/dist/edge/index.d.cts +27 -16
- package/dist/edge/index.d.cts.map +1 -1
- package/dist/edge/index.d.mts +27 -16
- package/dist/edge/index.d.mts.map +1 -1
- package/dist/edge/index.mjs +489 -116
- package/dist/edge/index.mjs.map +1 -1
- package/dist/node/index.cjs +489 -116
- package/dist/node/index.d.cts +27 -16
- package/dist/node/index.d.cts.map +1 -1
- package/dist/node/index.d.mts +27 -16
- package/dist/node/index.d.mts.map +1 -1
- package/dist/node/index.mjs +489 -116
- package/dist/node/index.mjs.map +1 -1
- package/package.json +6 -5
package/README.md
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# @solid-email/render
|
|
2
|
+
|
|
3
|
+
Render SolidJS email templates to HTML or plain text, and compile templates for repeated renders with slots.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
pnpm add @solid-email/render solid-js
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Install `@akin01/solid-email` when using the Solid Email component set.
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
pnpm add @akin01/solid-email
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Render HTML
|
|
18
|
+
|
|
19
|
+
```tsx
|
|
20
|
+
import { Body, Button, Container, Html, Text } from '@akin01/solid-email';
|
|
21
|
+
import { render } from '@solid-email/render';
|
|
22
|
+
|
|
23
|
+
const html = await render(() => (
|
|
24
|
+
<Html>
|
|
25
|
+
<Body>
|
|
26
|
+
<Container>
|
|
27
|
+
<Text>Welcome to Solid Email.</Text>
|
|
28
|
+
<Button href="https://example.com">Get started</Button>
|
|
29
|
+
</Container>
|
|
30
|
+
</Body>
|
|
31
|
+
</Html>
|
|
32
|
+
));
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Render plain text
|
|
36
|
+
|
|
37
|
+
```tsx
|
|
38
|
+
const text = await render(
|
|
39
|
+
() => (
|
|
40
|
+
<Html>
|
|
41
|
+
<Body>
|
|
42
|
+
<Container>
|
|
43
|
+
<Text>Hello Alice</Text>
|
|
44
|
+
<Button href="https://example.com/dashboard">Open dashboard</Button>
|
|
45
|
+
</Container>
|
|
46
|
+
</Body>
|
|
47
|
+
</Html>
|
|
48
|
+
),
|
|
49
|
+
{ plainText: true },
|
|
50
|
+
);
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Compile repeated renders
|
|
54
|
+
|
|
55
|
+
```tsx
|
|
56
|
+
import { Body, Button, Container, Html, Text } from '@akin01/solid-email';
|
|
57
|
+
import { compile, Slot, slot } from '@solid-email/render';
|
|
58
|
+
|
|
59
|
+
const compiled = await compile(
|
|
60
|
+
<Html>
|
|
61
|
+
<Body>
|
|
62
|
+
<Container>
|
|
63
|
+
<Text>
|
|
64
|
+
Hello <Slot name="name" />!
|
|
65
|
+
</Text>
|
|
66
|
+
<Button href={slot('url')}>Open dashboard</Button>
|
|
67
|
+
</Container>
|
|
68
|
+
</Body>
|
|
69
|
+
</Html>,
|
|
70
|
+
{ withPlainText: true },
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
const html = await compiled.render({ name: 'Alice', url: 'https://example.com/dashboard' });
|
|
74
|
+
const text = await compiled.render(
|
|
75
|
+
{ name: 'Alice', url: 'https://example.com/dashboard' },
|
|
76
|
+
{ plainText: true },
|
|
77
|
+
);
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Use `renderSync()` and `compileSync()` only for static templates that do not need async Solid rendering or `pretty` output.
|
|
81
|
+
|
|
82
|
+
See the repository README for benchmarks and advanced usage: https://github.com/Akin01/solid-email
|