@muscara/htmx-jsonata 0.0.6 → 0.0.7
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 +6 -29
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
[htmx extension](https://htmx.org/extensions) that provides [jsonata](https://jsonata.org) query functionality for htmx elements
|
|
4
4
|
|
|
5
|
-
> [!TIP]
|
|
6
|
-
> make sure htmx-jsonata is imported after htmx and jsonata.
|
|
7
|
-
|
|
8
5
|
```html
|
|
9
6
|
<!-- ... include jsonata -->
|
|
10
7
|
<!-- ... include htmx -->
|
|
11
|
-
<script src="https://unpkg.com/@muscara/htmx-jsonata/htmx-jsonata.min.js"></script>
|
|
8
|
+
<script src="https://unpkg.com/@muscara/htmx-jsonata@0.0.6/htmx-jsonata.min.js"></script>
|
|
12
9
|
```
|
|
13
10
|
|
|
11
|
+
> [!TIP]
|
|
12
|
+
> make sure htmx-jsonata is imported after htmx and jsonata.
|
|
13
|
+
|
|
14
14
|
## attributes
|
|
15
15
|
|
|
16
16
|
- `jn-url` (required): the url to fetch data from.
|
|
@@ -18,29 +18,6 @@
|
|
|
18
18
|
- `jn-path`: specifies a path to nested data (supports dot notation).
|
|
19
19
|
- `jn-each`: marks an element as a template to be cloned for each item in an array response.
|
|
20
20
|
|
|
21
|
-
##
|
|
22
|
-
|
|
23
|
-
[sample API response](https://my-json-server.typicode.com/kevinmuscara/htmx-jsonata/events)
|
|
24
|
-
|
|
25
|
-
```html
|
|
26
|
-
<div
|
|
27
|
-
jn-url="https://my-json-server.typicode.com/kevinmuscara/htmx-jsonata/events"
|
|
28
|
-
jn-query="
|
|
29
|
-
$[type='login'].{
|
|
30
|
-
'user': user,
|
|
31
|
-
'totalDuration': $sum(duration)
|
|
32
|
-
}
|
|
33
|
-
~> $distinct()"
|
|
34
|
-
>
|
|
35
|
-
<ul>
|
|
36
|
-
<li jn-each>
|
|
37
|
-
<span jn-path="user"></span>: <span jn-path="totalDuration"></span> min
|
|
38
|
-
</li>
|
|
39
|
-
</ul>
|
|
40
|
-
</div>
|
|
41
|
-
```
|
|
21
|
+
## try it
|
|
42
22
|
|
|
43
|
-
|
|
44
|
-
* alice: 15 min
|
|
45
|
-
* charlie: 8 min
|
|
46
|
-
* bob: 20 min
|
|
23
|
+
for live examples, use the [playground](https://htmx-jsonata.kevinmuscara.deno.net/)
|