html-express-js 1.0.0 → 1.0.3
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 +1 -1
- package/example/app.js +2 -2
- package/package.json +3 -3
- package/src/index.js +4 -7
package/README.md
CHANGED
package/example/app.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import express from 'express';
|
|
2
2
|
import { resolve } from 'path';
|
|
3
|
-
import
|
|
3
|
+
import htmlExpress from '../src/index.js';
|
|
4
4
|
|
|
5
5
|
const __dirname = resolve();
|
|
6
6
|
|
|
@@ -8,7 +8,7 @@ const app = express();
|
|
|
8
8
|
|
|
9
9
|
app.engine(
|
|
10
10
|
'js',
|
|
11
|
-
|
|
11
|
+
htmlExpress({
|
|
12
12
|
includesDir: 'includes',
|
|
13
13
|
notFoundView: '404/index',
|
|
14
14
|
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "html-express-js",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "An Express template engine to render HTML views using native JavaScript",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"url": "git+https://github.com/markcellus/html-express-js.git"
|
|
15
15
|
},
|
|
16
16
|
"keywords": [
|
|
17
|
-
"
|
|
17
|
+
"html",
|
|
18
18
|
"express",
|
|
19
19
|
"views",
|
|
20
20
|
"template",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"chokidar": "^3.5.3",
|
|
34
34
|
"express": "^4.18.1",
|
|
35
|
-
"prettier": "^2.7.
|
|
35
|
+
"prettier": "^2.7.1",
|
|
36
36
|
"release-it": "^15.0.0",
|
|
37
37
|
"reload": "^3.2.0"
|
|
38
38
|
}
|
package/src/index.js
CHANGED
|
@@ -24,14 +24,11 @@ async function renderHtmlFileTemplate(path, data, state) {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
|
-
* Renders a
|
|
27
|
+
* Renders a JS HTML file and adds all includes to state object.
|
|
28
28
|
*
|
|
29
29
|
* @param {string} filePath - The path to html file
|
|
30
30
|
* @param {object} data - Data to be made available in view
|
|
31
|
-
* @param {object} options - Options passed to
|
|
32
|
-
* @param {object} options.includesDir
|
|
33
|
-
* @param {object} options.viewsDir
|
|
34
|
-
* @param {object} options.notFoundView
|
|
31
|
+
* @param {object} options - Options passed to express
|
|
35
32
|
* @returns {string} HTML with includes available (appended to state)
|
|
36
33
|
*/
|
|
37
34
|
async function renderHtmlFile(filePath, data = {}, options = {}) {
|
|
@@ -71,12 +68,12 @@ export function html(strings, ...data) {
|
|
|
71
68
|
/**
|
|
72
69
|
* Returns a template engine view function.
|
|
73
70
|
*
|
|
74
|
-
* @param {object} opts
|
|
71
|
+
* @param {object} [opts]
|
|
75
72
|
* @param {object} [opts.includesDir]
|
|
76
73
|
* @param {object} [opts.notFoundView]
|
|
77
74
|
* @returns {Function}
|
|
78
75
|
*/
|
|
79
|
-
export default function
|
|
76
|
+
export default function (opts = {}) {
|
|
80
77
|
return async (filePath, data, callback) => {
|
|
81
78
|
const viewsDir = data.settings.views;
|
|
82
79
|
const includePath = opts.includesDir || 'includes';
|