htmv 0.0.63 → 0.0.65

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 CHANGED
@@ -156,9 +156,40 @@ For this, you'll need attribute binding. And HTMV has got your back! Simply add
156
156
 
157
157
  This tells HTMV's compiler: *"Don't add the attribute AND value, just add the attribute alone IF the value is truthy!"*
158
158
 
159
+ # Components
160
+ One of HTMV's key values is that a component is just a view. Therefore, your `example` view is already a component!
161
+
162
+ However, for HTMV to be able to differentiate it from an HTML element it must start with an uppercase (`Example`).
163
+
164
+ Let's create a header component with `bunx htmv gen view Header`
165
+
166
+ Inside we can make use of attributes like so:
167
+ ```html
168
+ <h1>{title}</h1>
169
+ <h2>{description}</h2>
170
+ ```
171
+ Lastly, in our `example` view, let's call it!
172
+ ```html
173
+ <Header title="My cool webpage" description="It's purpose is to test HTMV's components!"/>
174
+ ```
175
+
176
+ That's it. We can also make use of the `children` prop, like so:
177
+ ```html
178
+ <!-- example view -->
179
+ <Header description="It's purpose is to test HTMV's components!">My cool webpage</Header>
180
+ ```
181
+ ```html
182
+ <!-- Header view -->
183
+ <h1>{children}</h1>
184
+ <h2>{description}</h2>
185
+ ```
186
+
159
187
 
160
188
  # Hot reloading
161
- 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.
189
+ Hot reloading has not yet been fully developed. For now, you may develop with `bun dev`, which will take care of reloading on route code change. However, note that this won't include views or hot reloading in the browser.
190
+
191
+ # Linting
192
+ As of now, views work under the `.html` extension. However, that is subject to change in the future due to HTMV's language adding features which do not exist on normal HTML. Expect errors to appear on your editor when working with views. This will get sorted out once the `.htmv` extension becomes available.
162
193
 
163
194
  # Still have questions?
164
195
  How about asking the DeepWiki instead?
@@ -4,3 +4,5 @@ export declare function badRequest(body?: string | object, headers?: Headers): H
4
4
  export declare function created(body?: string | object, headers?: Headers): HttpResponse;
5
5
  export declare function ok(body?: string | object, headers?: Headers): HttpResponse;
6
6
  export declare function noContent(headers?: Headers): HttpResponse;
7
+ export declare function unauthorized(body?: string | object, headers?: Headers): HttpResponse;
8
+ export declare function forbidden(body?: string | object, headers?: Headers): HttpResponse;
@@ -14,3 +14,9 @@ export function ok(body, headers) {
14
14
  export function noContent(headers) {
15
15
  return requestHelper(204, undefined, headers);
16
16
  }
17
+ export function unauthorized(body, headers) {
18
+ return requestHelper(401, body, headers);
19
+ }
20
+ export function forbidden(body, headers) {
21
+ return requestHelper(403, body, headers);
22
+ }
@@ -4,8 +4,6 @@ import { viewsPath } from "./views";
4
4
  export const viewRegistry = {};
5
5
  export function addToViewRegistry(name, code) {
6
6
  viewRegistry[name] = code;
7
- console.log("Registered view", name, "with code:");
8
- console.log(code);
9
7
  }
10
8
  export async function registerViews() {
11
9
  const files = await deepReadDir(viewsPath);
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "htmv",
3
3
  "main": "dist/index.js",
4
4
  "type": "module",
5
- "version": "0.0.63",
5
+ "version": "0.0.65",
6
6
  "exports": {
7
7
  ".": {
8
8
  "types": "./dist/index.d.ts",