html-express-js 1.1.1 → 2.0.0
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/.nvmrc +1 -0
- package/.prettierignore +2 -1
- package/README.md +5 -5
- package/example/app.js +2 -2
- package/example/public/hello/index.js +1 -1
- package/example/public/index.js +1 -1
- package/example/public/not-found.js +1 -1
- package/jsconfig.json +1 -1
- package/package.json +6 -5
- package/src/index.js +2 -5
package/.nvmrc
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
16
|
package/.prettierignore
CHANGED
package/README.md
CHANGED
|
@@ -32,7 +32,7 @@ app.engine(
|
|
|
32
32
|
'js',
|
|
33
33
|
htmlExpress({
|
|
34
34
|
includesDir: 'includes', // where all includes reside
|
|
35
|
-
})
|
|
35
|
+
}),
|
|
36
36
|
);
|
|
37
37
|
// use engine
|
|
38
38
|
app.set('view engine', 'js');
|
|
@@ -40,7 +40,7 @@ app.set('view engine', 'js');
|
|
|
40
40
|
// set directory where all index.js pages are served
|
|
41
41
|
app.set('views', `${__dirname}/public`);
|
|
42
42
|
|
|
43
|
-
// render HTML in public/
|
|
43
|
+
// render HTML in public/homepage.js with data
|
|
44
44
|
app.get('/', function (req, res, next) {
|
|
45
45
|
res.render('homepage', {
|
|
46
46
|
title: 'Awesome Homepage',
|
|
@@ -55,7 +55,7 @@ app.use(
|
|
|
55
55
|
staticIndexHandler({
|
|
56
56
|
viewsDir: `${__dirname}/public`, // root views directory to serve all index.js files
|
|
57
57
|
notFoundView: '404/index', // relative to viewsDir above
|
|
58
|
-
})
|
|
58
|
+
}),
|
|
59
59
|
);
|
|
60
60
|
```
|
|
61
61
|
|
|
@@ -80,7 +80,7 @@ export const view = () => html`
|
|
|
80
80
|
import { html } from 'html-express-js';
|
|
81
81
|
|
|
82
82
|
export const view = (data, state) => html`
|
|
83
|
-
<!
|
|
83
|
+
<!doctype html>
|
|
84
84
|
<html lang="en">
|
|
85
85
|
<head>
|
|
86
86
|
${state.includes.head}
|
|
@@ -88,7 +88,7 @@ export const view = (data, state) => html`
|
|
|
88
88
|
</head>
|
|
89
89
|
|
|
90
90
|
<body>
|
|
91
|
-
<h1>This is the homepage</h1>
|
|
91
|
+
<h1>This is the homepage for ${data.name}</h1>
|
|
92
92
|
</body>
|
|
93
93
|
</html>
|
|
94
94
|
`;
|
package/example/app.js
CHANGED
|
@@ -10,7 +10,7 @@ app.engine(
|
|
|
10
10
|
'js',
|
|
11
11
|
htmlExpress({
|
|
12
12
|
includesDir: 'includes',
|
|
13
|
-
})
|
|
13
|
+
}),
|
|
14
14
|
);
|
|
15
15
|
|
|
16
16
|
app.set('view engine', 'js');
|
|
@@ -30,7 +30,7 @@ app.use(
|
|
|
30
30
|
staticIndexHandler({
|
|
31
31
|
viewsDir: `${__dirname}/example/public`,
|
|
32
32
|
notFoundView: 'not-found', // OPTIONAL: defaults to `404/index`
|
|
33
|
-
})
|
|
33
|
+
}),
|
|
34
34
|
);
|
|
35
35
|
|
|
36
36
|
export default app;
|
package/example/public/index.js
CHANGED
package/jsconfig.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "html-express-js",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "An Express template engine to render HTML views using native JavaScript",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -31,14 +31,15 @@
|
|
|
31
31
|
},
|
|
32
32
|
"homepage": "https://github.com/markcellus/html-express-js#readme",
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"glob": "^
|
|
34
|
+
"glob": "^10.2.2"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
+
"@types/glob": "^8.1.0",
|
|
37
38
|
"chokidar": "^3.5.3",
|
|
38
39
|
"express": "^4.18.1",
|
|
39
|
-
"husky": "^
|
|
40
|
-
"prettier": "^
|
|
41
|
-
"release-it": "^
|
|
40
|
+
"husky": "^9.0.7",
|
|
41
|
+
"prettier": "^3.0.3",
|
|
42
|
+
"release-it": "^17.0.0",
|
|
42
43
|
"reload": "^3.2.0"
|
|
43
44
|
}
|
|
44
45
|
}
|
package/src/index.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { basename, extname } from 'path';
|
|
2
|
-
import {
|
|
3
|
-
import g from 'glob';
|
|
2
|
+
import { glob } from 'glob';
|
|
4
3
|
import { stat } from 'fs/promises';
|
|
5
4
|
|
|
6
|
-
const glob = promisify(g);
|
|
7
|
-
|
|
8
5
|
/**
|
|
9
6
|
* Renders an HTML template in a file.
|
|
10
7
|
*
|
|
@@ -44,7 +41,7 @@ async function renderHtmlFile(filePath, data = {}, instanceOptions = {}) {
|
|
|
44
41
|
state.includes[key] = await renderHtmlFileTemplate(
|
|
45
42
|
includePath,
|
|
46
43
|
data,
|
|
47
|
-
state
|
|
44
|
+
state,
|
|
48
45
|
);
|
|
49
46
|
}
|
|
50
47
|
return await renderHtmlFileTemplate(filePath, data, state);
|