@thi.ng/hiccup 5.1.17 → 5.1.18
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/CHANGELOG.md +1 -1
- package/README.md +17 -0
- package/package.json +4 -4
- package/serialize.d.ts +5 -0
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -216,6 +216,8 @@ Tag names support
|
|
|
216
216
|
style ID & class attribute expansion:
|
|
217
217
|
|
|
218
218
|
```ts
|
|
219
|
+
import { serialize } from "@thi.ng/hiccup";
|
|
220
|
+
|
|
219
221
|
serialize(
|
|
220
222
|
["div#yo.hello.world", "Look ma, ", ["strong", "no magic!"]]
|
|
221
223
|
);
|
|
@@ -236,6 +238,8 @@ If the 2nd array element is not a plain object, it's treated as normal
|
|
|
236
238
|
child node (see previous example).
|
|
237
239
|
|
|
238
240
|
```ts
|
|
241
|
+
import { serialize } from "@thi.ng/hiccup";
|
|
242
|
+
|
|
239
243
|
serialize(
|
|
240
244
|
["div.notice",
|
|
241
245
|
{
|
|
@@ -288,6 +292,8 @@ Function values for event attributes (any attrib name starting with
|
|
|
288
292
|
### Simple components
|
|
289
293
|
|
|
290
294
|
```ts
|
|
295
|
+
import { serialize } from "@thi.ng/hiccup";
|
|
296
|
+
|
|
291
297
|
const thumb = (src) => ["img.thumb", { src, alt: "thumbnail" }];
|
|
292
298
|
|
|
293
299
|
serialize(
|
|
@@ -315,6 +321,8 @@ The context object should contain any global component configuration,
|
|
|
315
321
|
e.g. for theming purposes.
|
|
316
322
|
|
|
317
323
|
```ts
|
|
324
|
+
import { serialize } from "@thi.ng/hiccup";
|
|
325
|
+
|
|
318
326
|
const header = (ctx, body) =>
|
|
319
327
|
["h1", ctx.theme.title, body];
|
|
320
328
|
|
|
@@ -344,6 +352,8 @@ yourself. Likewise, if a component function doesn't make use of the context you
|
|
|
344
352
|
can use either:
|
|
345
353
|
|
|
346
354
|
```ts
|
|
355
|
+
import { serialize } from "@thi.ng/hiccup";
|
|
356
|
+
|
|
347
357
|
// skip the context arg and require direct invocation
|
|
348
358
|
const div = (attribs, body) => ["div", attribs, body];
|
|
349
359
|
|
|
@@ -354,6 +364,8 @@ serialize(div({id: "foo"}, "bar"));
|
|
|
354
364
|
Or...
|
|
355
365
|
|
|
356
366
|
```ts
|
|
367
|
+
import { serialize } from "@thi.ng/hiccup";
|
|
368
|
+
|
|
357
369
|
// ignore the first arg (context) and support both direct & indirect calls
|
|
358
370
|
const div = (_, attribs, body) => ["div", attribs, body];
|
|
359
371
|
|
|
@@ -567,7 +579,10 @@ Single or multiline comments can be included using the special `COMMENT`
|
|
|
567
579
|
tag (`__COMMENT__`) (always WITHOUT attributes!).
|
|
568
580
|
|
|
569
581
|
```ts
|
|
582
|
+
import { COMMENT } from "@thi.ng/hiccup";
|
|
583
|
+
|
|
570
584
|
[COMMENT, "Hello world"]
|
|
585
|
+
// serializes to:
|
|
571
586
|
// <!-- Hello world -->
|
|
572
587
|
|
|
573
588
|
[COMMENT, "Hello", "world"]
|
|
@@ -663,6 +678,8 @@ that function is called. The return value the function MUST be a valid
|
|
|
663
678
|
new tree (or undefined).
|
|
664
679
|
|
|
665
680
|
```ts
|
|
681
|
+
import { serialize } from "@thi.ng/hiccup";
|
|
682
|
+
|
|
666
683
|
const foo = (ctx, a, b) => ["div#" + a, ctx.foo, b];
|
|
667
684
|
|
|
668
685
|
serialize([foo, "id", "body"], { foo: { class: "black" } })
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/hiccup",
|
|
3
|
-
"version": "5.1.
|
|
3
|
+
"version": "5.1.18",
|
|
4
4
|
"description": "HTML/SVG/XML serialization of nested data structures, iterables & closures",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -38,11 +38,11 @@
|
|
|
38
38
|
"@thi.ng/api": "^8.9.27",
|
|
39
39
|
"@thi.ng/checks": "^3.5.1",
|
|
40
40
|
"@thi.ng/errors": "^2.4.19",
|
|
41
|
-
"@thi.ng/strings": "^3.7.
|
|
41
|
+
"@thi.ng/strings": "^3.7.20"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@microsoft/api-extractor": "^7.40.1",
|
|
45
|
-
"@thi.ng/atom": "^5.2.
|
|
45
|
+
"@thi.ng/atom": "^5.2.35",
|
|
46
46
|
"esbuild": "^0.20.0",
|
|
47
47
|
"rimraf": "^5.0.5",
|
|
48
48
|
"typedoc": "^0.25.7",
|
|
@@ -127,5 +127,5 @@
|
|
|
127
127
|
],
|
|
128
128
|
"year": 2016
|
|
129
129
|
},
|
|
130
|
-
"gitHead": "
|
|
130
|
+
"gitHead": "df9e312af741d87e6b450afcfea6a6e381662b1e\n"
|
|
131
131
|
}
|
package/serialize.d.ts
CHANGED
|
@@ -100,6 +100,8 @@ export interface SerializeOpts {
|
|
|
100
100
|
* interface.
|
|
101
101
|
*
|
|
102
102
|
* ```js
|
|
103
|
+
* import { serialize } from "@thi.ng/hiccup";
|
|
104
|
+
*
|
|
103
105
|
* const foo = (ctx, a, b) => ["div#" + a, ctx.foo, b];
|
|
104
106
|
*
|
|
105
107
|
* serialize([foo, "id", "body"], { ctx: { foo: { class: "black" } } })
|
|
@@ -122,7 +124,10 @@ export interface SerializeOpts {
|
|
|
122
124
|
* (`"__COMMENT__"`) (always WITHOUT attributes!).
|
|
123
125
|
*
|
|
124
126
|
* ```js
|
|
127
|
+
* import { COMMENT } from "@thi.ng/hiccup";
|
|
128
|
+
*
|
|
125
129
|
* [COMMENT, "Hello world"]
|
|
130
|
+
* // serializes to:
|
|
126
131
|
* // <!-- Hello world -->
|
|
127
132
|
*
|
|
128
133
|
* [COMMENT, "Hello", "world"]
|