turbo-html2pdf-template 0.1.0 → 0.1.2
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 +32 -0
- package/package.json +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# turbo-html2pdf-template
|
|
2
|
+
|
|
3
|
+
Author [**turbo-html2pdf**](https://www.npmjs.com/package/turbo-html2pdf) document
|
|
4
|
+
templates with **plain functions** — no React, no JSX, no build step. The helpers
|
|
5
|
+
produce a template *source string* (HTML + Jinja + `t:` directives) you hand to the
|
|
6
|
+
engine.
|
|
7
|
+
|
|
8
|
+
```ts
|
|
9
|
+
import { each, ifBlock, expr } from 'turbo-html2pdf-template'
|
|
10
|
+
import { compile } from 'turbo-html2pdf' // the engine (Node) — or turbo-html2pdf-wasm in the browser
|
|
11
|
+
|
|
12
|
+
const source = [
|
|
13
|
+
`<h1>Invoice ${expr('data.number')}</h1>`,
|
|
14
|
+
each('data.rows', 'row',
|
|
15
|
+
`<p>${expr('row.description')} — ${expr('row.amount | currency')}</p>`),
|
|
16
|
+
ifBlock('data.paid', `<div class="stamp">PAID</div>`),
|
|
17
|
+
].join('')
|
|
18
|
+
|
|
19
|
+
const program = compile(source)
|
|
20
|
+
const { pdf } = program.render({ data: { number: 42, rows: [], paid: true } })
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Helpers mirror the DSL: `ifBlock`/`elseIf`/`elseBlock`, `switchBlock`/`caseBlock`/
|
|
24
|
+
`defaultBlock`, `each`, `include`, `expr`, `runningHeader`/`runningFooter`, and the
|
|
25
|
+
paged-media directives.
|
|
26
|
+
|
|
27
|
+
This package only produces the template string; rendering is done by
|
|
28
|
+
**turbo-html2pdf** (Node) or **turbo-html2pdf-wasm** (browser). See the
|
|
29
|
+
[main README](https://github.com/miaskiewicz/turbo-html2pdf) and the
|
|
30
|
+
[DSL / API docs](https://github.com/miaskiewicz/turbo-html2pdf/tree/main/docs).
|
|
31
|
+
|
|
32
|
+
MIT.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "turbo-html2pdf-template",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"description": "Author turbo-html2pdf PDF templates with plain functions (no React) — HTML/CSS + Jinja to PDF.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"publishConfig": {
|