htmv 0.0.31 → 0.0.32
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 +5 -1
- package/dist/views.js +7 -1
- package/package.json +1 -1
- package/src/views.ts +8 -2
package/README.md
CHANGED
|
@@ -109,4 +109,8 @@ bunx htmv@latest gen view MyCoolView --path cool_stuff/my_custom_views_folder
|
|
|
109
109
|
```
|
|
110
110
|
|
|
111
111
|
# Hot reloading
|
|
112
|
-
Having to restart the server every time you make a change can be quite tedious. HTMV takes care of this thanks to Bun. Just develop with `bun dev` and it should work out of the box! Note that this does not include hot reloading in the browser. As of now, you have to refresh the page to see new changes. It doesn't update in real time.
|
|
112
|
+
Having to restart the server every time you make a change can be quite tedious. HTMV takes care of this thanks to Bun. Just develop with `bun dev` and it should work out of the box! Note that this does not include hot reloading in the browser. As of now, you have to refresh the page to see new changes. It doesn't update in real time.
|
|
113
|
+
|
|
114
|
+
# Still have questions?
|
|
115
|
+
How about asking the DeepWiki instead?
|
|
116
|
+
[](https://deepwiki.com/Fabrisdev/htmv)
|
package/dist/views.js
CHANGED
|
@@ -26,7 +26,7 @@ export async function view(view, props) {
|
|
|
26
26
|
const propName = isNegated
|
|
27
27
|
? propNameWithPrefix.slice(1)
|
|
28
28
|
: propNameWithPrefix;
|
|
29
|
-
const exists = props[propName]
|
|
29
|
+
const exists = isset(props[propName]);
|
|
30
30
|
if (isNegated ? !exists : exists)
|
|
31
31
|
return innerContent;
|
|
32
32
|
return "";
|
|
@@ -35,3 +35,9 @@ export async function view(view, props) {
|
|
|
35
35
|
headers: { "Content-Type": "text/html; charset=utf-8" },
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
|
+
function isset(prop) {
|
|
39
|
+
if (Array.isArray(prop)) {
|
|
40
|
+
return prop.length > 0;
|
|
41
|
+
}
|
|
42
|
+
return prop !== undefined && prop !== null;
|
|
43
|
+
}
|
package/package.json
CHANGED
package/src/views.ts
CHANGED
|
@@ -44,8 +44,7 @@ export async function view(view: string, props: Record<string, unknown>) {
|
|
|
44
44
|
const propName = isNegated
|
|
45
45
|
? propNameWithPrefix.slice(1)
|
|
46
46
|
: propNameWithPrefix;
|
|
47
|
-
const exists =
|
|
48
|
-
props[propName] !== undefined && props[propName] !== null;
|
|
47
|
+
const exists = isset(props[propName]);
|
|
49
48
|
|
|
50
49
|
if (isNegated ? !exists : exists) return innerContent;
|
|
51
50
|
return "";
|
|
@@ -55,3 +54,10 @@ export async function view(view: string, props: Record<string, unknown>) {
|
|
|
55
54
|
headers: { "Content-Type": "text/html; charset=utf-8" },
|
|
56
55
|
});
|
|
57
56
|
}
|
|
57
|
+
|
|
58
|
+
function isset(prop: unknown) {
|
|
59
|
+
if (Array.isArray(prop)) {
|
|
60
|
+
return prop.length > 0;
|
|
61
|
+
}
|
|
62
|
+
return prop !== undefined && prop !== null;
|
|
63
|
+
}
|