express-handlebars
Advanced tools
Comparing version 6.0.0 to 6.0.1
@@ -0,1 +1,10 @@ | ||
## [6.0.1](https://github.com/express-handlebars/express-handlebars/compare/v6.0.0...v6.0.1) (2021-11-13) | ||
### Bug Fixes | ||
* fix types ([f4de857](https://github.com/express-handlebars/express-handlebars/commit/f4de8577d5ad4510f4c5286cdee300dd27c6abfc)) | ||
* remove default export ([a7f38a1](https://github.com/express-handlebars/express-handlebars/commit/a7f38a1d3127d63450b10b3f3539e3ce8131b677)) | ||
* update examples ([1b1f5f7](https://github.com/express-handlebars/express-handlebars/commit/1b1f5f7b818985d433f6dc0398f7866c62b6cdea)) | ||
# [6.0.0](https://github.com/express-handlebars/express-handlebars/compare/v5.3.5...v6.0.0) (2021-11-13) | ||
@@ -2,0 +11,0 @@ |
@@ -435,1 +435,2 @@ "use strict"; | ||
exports.default = ExpressHandlebars; | ||
//# sourceMappingURL=express-handlebars.js.map |
@@ -7,17 +7,6 @@ "use strict"; | ||
*/ | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.create = exports.ExpressHandlebars = void 0; | ||
exports.engine = exports.create = exports.ExpressHandlebars = void 0; | ||
var express_handlebars_1 = require("./express-handlebars"); | ||
exports.ExpressHandlebars = express_handlebars_1.default; | ||
__exportStar(require("./types"), exports); | ||
function create(config) { | ||
@@ -28,8 +17,7 @@ if (config === void 0) { config = {}; } | ||
exports.create = create; | ||
function exphbs(config) { | ||
function engine(config) { | ||
if (config === void 0) { config = {}; } | ||
return create(config).engine; | ||
} | ||
exports.default = exphbs; | ||
exphbs.create = create; | ||
exphbs.ExpressHandlebars = express_handlebars_1.default; | ||
exports.engine = engine; | ||
//# sourceMappingURL=index.js.map |
@@ -12,3 +12,3 @@ /* | ||
import * as globSync from "glob"; | ||
import { | ||
import type { | ||
UnknownObject, | ||
@@ -30,3 +30,3 @@ FunctionObject, | ||
RenameFunction, | ||
} from "./types"; | ||
} from "../types"; | ||
@@ -33,0 +33,0 @@ const glob = promisify(globSync); |
@@ -11,5 +11,4 @@ /* | ||
Engine, | ||
} from "./types"; | ||
} from "../types"; | ||
export * from "./types"; | ||
export { ExpressHandlebars }; | ||
@@ -21,6 +20,4 @@ | ||
export default function exphbs (config: ConfigOptions = {}): Engine { | ||
export function engine (config: ConfigOptions = {}): Engine { | ||
return create(config).engine; | ||
} | ||
exphbs.create = create; | ||
exphbs.ExpressHandlebars = ExpressHandlebars; |
{ | ||
"name": "express-handlebars", | ||
"description": "A Handlebars view engine for Express which doesn't suck.", | ||
"version": "6.0.0", | ||
"version": "6.0.1", | ||
"homepage": "https://github.com/express-handlebars/express-handlebars", | ||
@@ -6,0 +6,0 @@ "keywords": [ |
@@ -67,3 +67,3 @@ Express Handlebars | ||
## Danger 🔥 | ||
Never put objects on the `req` object straight in as the data, this can allow hackers to run XSS attacks. Always make sure you are destructuring the values on objects like `req.query` and `req.params`. See https://blog.shoebpatel.com/2021/01/23/The-Secret-Parameter-LFR-and-Potential-RCE-in-NodeJS-Apps/ for more details. | ||
@@ -95,11 +95,12 @@ | ||
```javascript | ||
var express = require('express'); | ||
var exphbs = require('express-handlebars'); | ||
import express from 'express'; | ||
import { engine } from 'express-handlebars'; | ||
var app = express(); | ||
const app = express(); | ||
app.engine('handlebars', exphbs()); | ||
app.engine('handlebars', engine()); | ||
app.set('view engine', 'handlebars'); | ||
app.set("views", "./views"); | ||
app.get('/', function (req, res) { | ||
app.get('/', (req, res) => { | ||
res.render('home'); | ||
@@ -153,7 +154,7 @@ }); | ||
```javascript | ||
var express = require('express'); | ||
var exphbs = require('express-handlebars'); | ||
import express from 'express'; | ||
import { create } from 'express-handlebars'; | ||
var app = express(); | ||
var hbs = exphbs.create({ /* config */ }); | ||
const app = express(); | ||
const hbs = create({ /* config */ }); | ||
@@ -163,2 +164,3 @@ // Register `hbs.engine` with the Express app. | ||
app.set('view engine', 'handlebars'); | ||
app.set("views", "./views"); | ||
@@ -200,3 +202,3 @@ // ...still have a reference to `hbs`, on which methods like `getPartials()` | ||
```javascript | ||
app.get('/', function (req, res, next) { | ||
app.get('/', (req, res, next) => { | ||
res.render('home', {layout: false}); | ||
@@ -219,12 +221,12 @@ }); | ||
```javascript | ||
var express = require('express'); | ||
var exphbs = require('express-handlebars'); | ||
import express from 'express'; | ||
import { create } from 'express-handlebars'; | ||
var app = express(); | ||
const app = express(); | ||
var hbs = exphbs.create({ | ||
const hbs = create({ | ||
// Specify helpers which are only registered on this instance. | ||
helpers: { | ||
foo: function () { return 'FOO!'; }, | ||
bar: function () { return 'BAR!'; } | ||
foo() { return 'FOO!'; }, | ||
bar() { return 'BAR!'; } | ||
} | ||
@@ -235,4 +237,5 @@ }); | ||
app.set('view engine', 'handlebars'); | ||
app.set("views", "./views"); | ||
app.get('/', function (req, res, next) { | ||
app.get('/', (req, res, next) => { | ||
res.render('home', { | ||
@@ -243,3 +246,3 @@ showTitle: true, | ||
helpers: { | ||
foo: function () { return 'foo.'; } | ||
foo() { return 'foo.'; } | ||
} | ||
@@ -320,9 +323,11 @@ }); | ||
```javascript | ||
var exphbs = require('express-handlebars'); | ||
import { engine, create, ExpressHandlebars } from 'express-handlebars'; | ||
// Using the engine factory: | ||
exphbs({ /* config */ }); | ||
engine({ /* config */ }); | ||
// Create an instance: | ||
exphbs.create({ /* config */ }); | ||
create({ /* config */ }); | ||
new ExpressHandlebars({ /* config */}) | ||
``` | ||
@@ -341,9 +346,10 @@ | ||
```javascript | ||
var express = require('express'); | ||
var exphbs = require('express-handlebars'); | ||
import express from 'express'; | ||
import { engine } from 'express-handlebars'; | ||
var app = express(); | ||
const app = express(); | ||
app.engine('.hbs', exphbs({extname: '.hbs'})); | ||
app.engine('.hbs', engine({extname: '.hbs'})); | ||
app.set('view engine', '.hbs'); | ||
app.set("views", "./views"); | ||
``` | ||
@@ -439,4 +445,5 @@ | ||
```javascript | ||
var hbs = require('express-handlebars').create(); | ||
import { create } from 'express-handlebars'; | ||
const hbs = create(); | ||
hbs.getPartials().then(function (partials) { | ||
@@ -443,0 +450,0 @@ console.log(partials); |
import * as path from "path"; | ||
import expressHandlebars from "../lib/index"; | ||
import { | ||
import * as expressHandlebars from "../lib/index"; | ||
import type { | ||
TemplateDelegateObject, | ||
} from "../lib/types"; | ||
} from "../types"; | ||
@@ -361,3 +361,3 @@ function fixturePath (filePath = "") { | ||
const cb = () => { /* empty */ }; | ||
expressHandlebars()("view", {}, cb); | ||
expressHandlebars.engine()("view", {}, cb); | ||
expect(expressHandlebars.ExpressHandlebars.prototype.renderView).toHaveBeenCalledWith("view", {}, cb); | ||
@@ -367,3 +367,3 @@ }); | ||
test("should render html", async () => { | ||
const renderView = expressHandlebars({ defaultLayout: null }); | ||
const renderView = expressHandlebars.engine({ defaultLayout: null }); | ||
const viewPath = fixturePath("render-text.handlebars"); | ||
@@ -370,0 +370,0 @@ const html = await renderView(viewPath, { text: "test text" }); |
{ | ||
"compilerOptions": { | ||
"outDir": "./dist", | ||
"target": "es5" | ||
"target": "es5", | ||
"declaration": true, | ||
"sourceMap": true | ||
}, | ||
"include": ["./lib/**/*"] | ||
} |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
136253
36
1720
607
0