htmv 0.0.27 → 0.0.29
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/dist/types.d.ts +12 -0
- package/dist/types.js +0 -0
- package/dist/views.js +1 -1
- package/package.json +1 -1
- package/src/views.ts +1 -1
- /package/src/{types.d.ts → types.ts} +0 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type RouteParams = {
|
|
2
|
+
query: Record<string, string>;
|
|
3
|
+
request: Request;
|
|
4
|
+
params: Record<string, string>;
|
|
5
|
+
};
|
|
6
|
+
export type Paths = {
|
|
7
|
+
routes: string;
|
|
8
|
+
views: string;
|
|
9
|
+
public: string;
|
|
10
|
+
port: number;
|
|
11
|
+
};
|
|
12
|
+
export type RouteFn = (_: RouteParams) => Promise<Response> | Response | Promise<string> | string;
|
package/dist/types.js
ADDED
|
File without changes
|
package/dist/views.js
CHANGED
|
@@ -10,7 +10,7 @@ export async function view(view, props) {
|
|
|
10
10
|
const filePath = path.join(viewsPath, `${view}.html`);
|
|
11
11
|
const code = await fs.readFile(filePath, "utf-8");
|
|
12
12
|
const replacedCode = code
|
|
13
|
-
.replace(/{(
|
|
13
|
+
.replace(/{(\w+)}/g, (_, propName) => {
|
|
14
14
|
return props[propName];
|
|
15
15
|
})
|
|
16
16
|
.replace(/<Isset\s+(\w+)>([\s\S]*?)<\/Isset>/g, (_, propNameWithPrefix, innerContent) => {
|
package/package.json
CHANGED
package/src/views.ts
CHANGED
|
@@ -15,7 +15,7 @@ export async function view(view: string, props: Record<string, unknown>) {
|
|
|
15
15
|
const filePath = path.join(viewsPath, `${view}.html`);
|
|
16
16
|
const code = await fs.readFile(filePath, "utf-8");
|
|
17
17
|
const replacedCode = code
|
|
18
|
-
.replace(/{(
|
|
18
|
+
.replace(/{(\w+)}/g, (_, propName) => {
|
|
19
19
|
return props[propName] as string;
|
|
20
20
|
})
|
|
21
21
|
.replace(
|
|
File without changes
|