Skip to content

Commit

Permalink
update: hbs engine dependency and tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
ItzNotABug committed Oct 27, 2024
1 parent 2575f13 commit 90e188b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
6 changes: 3 additions & 3 deletions source/appexpress.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,15 +230,15 @@ class AppExpress {
const extensions = Array.isArray(ext) ? ext : [ext];

extensions.forEach((extension) => {
// `hbs`, `ejs`, `pug` have this variable,
// `ejs` & `pug` have this variable,
// that is handled by express internally.
if (engine.hasOwnProperty('__express')) {
this.#engine.set(extension, engine.__express);
} else if (typeof engine === 'function' && engine.length >= 3) {
} else if (typeof engine === 'function') {
this.#engine.set(extension, engine);
} else {
throw new Error(
`Invalid engine: It must either have a '__express' property or be a function with at least 3 parameters. Received function length: ${engine.length}`,
`Invalid engine: It must either have a '__express' property or be a function.`,
);
}
});
Expand Down
2 changes: 1 addition & 1 deletion source/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"ejs": "3.1.10",
"showdown": "2.1.0",
"prettier": "3.3.3",
"express-hbs": "2.5.0",
"express-handlebars": "8.0.1",
"@itznotabug/appexpress-nocookies": "^0.0.4"
},
"keywords": [
Expand Down
6 changes: 4 additions & 2 deletions source/tests/src/function/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import ejs from 'ejs';
import pug from 'pug';
import hbs from 'express-hbs';
import showdown from 'showdown';
import hbs from 'express-handlebars';

import fs from 'fs';
import path from 'path';
Expand Down Expand Up @@ -37,7 +37,9 @@ express.engine('pug', pug); // pub
// hbs, html
express.engine(
['hbs', 'html'],
hbs.express4({
hbs.engine({
extname: 'hbs',
defaultLayout: false,
partialsDir: path.join(AppExpress.baseDirectory, 'views/partials'),
}),
);
Expand Down

0 comments on commit 90e188b

Please sign in to comment.