@financial-times/dotcom-server-handlebars 11.3.0 → 12.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/dist/node/PageKitHandlebars.d.ts +1 -1
- package/dist/node/PageKitHandlebars.js +3 -3
- package/dist/node/findPartialFiles.js +1 -1
- package/dist/node/helpers/array.js +1 -1
- package/dist/node/helpers/capture.js +1 -1
- package/dist/node/helpers/concat.js +1 -1
- package/dist/node/helpers/dateformat.js +2 -2
- package/dist/node/helpers/encode.js +1 -1
- package/dist/node/helpers/ifAll.js +1 -1
- package/dist/node/helpers/ifEquals.js +1 -1
- package/dist/node/helpers/ifEqualsSome.js +1 -1
- package/dist/node/helpers/ifSome.js +1 -1
- package/dist/node/helpers/json.js +1 -1
- package/dist/node/helpers/renderReactComponent.js +1 -1
- package/dist/node/helpers/resize.js +1 -1
- package/dist/node/helpers/slice.js +1 -1
- package/dist/node/helpers/unlessAll.js +1 -1
- package/dist/node/helpers/unlessEquals.js +1 -1
- package/dist/node/helpers/unlessSome.js +1 -1
- package/dist/node/index.js +5 -1
- package/dist/node/loadFileContents.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -3066
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Handlebars, { HelperDelegate, TemplateDelegate } from 'handlebars';
|
|
2
2
|
import { TRenderCallback, TPartialTemplates, TFilePaths } from './types';
|
|
3
|
-
export
|
|
3
|
+
export type TPageKitHandlebarsOptions = {
|
|
4
4
|
/**
|
|
5
5
|
* An instance of Handlebars to use.
|
|
6
6
|
* @default require('handlebars')
|
|
@@ -25,14 +25,14 @@ const defaultOptions = {
|
|
|
25
25
|
class PageKitHandlebars {
|
|
26
26
|
constructor(userOptions = {}) {
|
|
27
27
|
this.cache = new Map();
|
|
28
|
-
this.options = mixin_deep_1.default({}, defaultOptions, userOptions);
|
|
28
|
+
this.options = (0, mixin_deep_1.default)({}, defaultOptions, userOptions);
|
|
29
29
|
// Create a point for Express to mount as a view engine
|
|
30
30
|
this.engine = this.renderView.bind(this);
|
|
31
31
|
}
|
|
32
32
|
loadPartials() {
|
|
33
33
|
let partials = this.cache.get('__partials__');
|
|
34
34
|
if (partials === undefined) {
|
|
35
|
-
partials = findPartialFiles_1.default(this.options.rootDirectory, this.options.partialPaths);
|
|
35
|
+
partials = (0, findPartialFiles_1.default)(this.options.rootDirectory, this.options.partialPaths);
|
|
36
36
|
if (this.options.cache) {
|
|
37
37
|
this.cache.set('__partials__', partials);
|
|
38
38
|
}
|
|
@@ -50,7 +50,7 @@ class PageKitHandlebars {
|
|
|
50
50
|
}
|
|
51
51
|
let template = this.cache.get(filePath);
|
|
52
52
|
if (template === undefined) {
|
|
53
|
-
const contents = loadFileContents_1.default(filePath);
|
|
53
|
+
const contents = (0, loadFileContents_1.default)(filePath);
|
|
54
54
|
const hbs = this.options.handlebars || handlebars_1.default;
|
|
55
55
|
template = hbs.compile(contents);
|
|
56
56
|
if (this.options.cache) {
|
|
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.default = loadPartialFiles;
|
|
6
7
|
const path_1 = __importDefault(require("path"));
|
|
7
8
|
const glob_1 = __importDefault(require("glob"));
|
|
8
9
|
function loadPartialFiles(cwd, partialPaths) {
|
|
@@ -21,4 +22,3 @@ function loadPartialFiles(cwd, partialPaths) {
|
|
|
21
22
|
});
|
|
22
23
|
return partialFiles;
|
|
23
24
|
}
|
|
24
|
-
exports.default = loadPartialFiles;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = array;
|
|
3
4
|
function array(...args) {
|
|
4
5
|
if (args.length < 2) {
|
|
5
6
|
throw Error('At least one parameter must be provided');
|
|
@@ -7,4 +8,3 @@ function array(...args) {
|
|
|
7
8
|
// The final parameter will always be an instance of HelperOptions
|
|
8
9
|
return args.slice(0, -1);
|
|
9
10
|
}
|
|
10
|
-
exports.default = array;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = capture;
|
|
3
4
|
function capture(name, options) {
|
|
4
5
|
if (this.hasOwnProperty(name)) {
|
|
5
6
|
throw Error(`Template data property "${name}" has already been declared.`);
|
|
@@ -8,4 +9,3 @@ function capture(name, options) {
|
|
|
8
9
|
this[name] = options.fn(this);
|
|
9
10
|
}
|
|
10
11
|
}
|
|
11
|
-
exports.default = capture;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = concat;
|
|
3
4
|
function concat(...args) {
|
|
4
5
|
if (args.length < 3) {
|
|
5
6
|
throw Error('At least two parameters must be provided');
|
|
@@ -7,4 +8,3 @@ function concat(...args) {
|
|
|
7
8
|
// The final parameter will always be an intance of HelperOptions
|
|
8
9
|
return args.slice(0, -1).join('');
|
|
9
10
|
}
|
|
10
|
-
exports.default = concat;
|
|
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.default = dateformat;
|
|
6
7
|
const dateformat_1 = __importDefault(require("dateformat"));
|
|
7
8
|
function dateformat(...args) {
|
|
8
9
|
if (args.length > 2) {
|
|
@@ -10,6 +11,5 @@ function dateformat(...args) {
|
|
|
10
11
|
}
|
|
11
12
|
const options = args.pop();
|
|
12
13
|
const format = args[0] || 'isoUtcDateTime';
|
|
13
|
-
return dateformat_1.default(options.fn(this), format);
|
|
14
|
+
return (0, dateformat_1.default)(options.fn(this), format);
|
|
14
15
|
}
|
|
15
|
-
exports.default = dateformat;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = encode;
|
|
3
4
|
function encode(...args) {
|
|
4
5
|
if (args.length !== 2) {
|
|
5
6
|
throw Error('Incorrect number of parameters provided');
|
|
@@ -12,4 +13,3 @@ function encode(...args) {
|
|
|
12
13
|
return encodeURIComponent(args[0]);
|
|
13
14
|
}
|
|
14
15
|
}
|
|
15
|
-
exports.default = encode;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = ifAll;
|
|
3
4
|
function ifAll(...args) {
|
|
4
5
|
if (args.length < 2) {
|
|
5
6
|
throw Error('At least one parameter must be provided');
|
|
@@ -8,4 +9,3 @@ function ifAll(...args) {
|
|
|
8
9
|
const condition = args.every(Boolean);
|
|
9
10
|
return condition ? options.fn(this) : options.inverse(this);
|
|
10
11
|
}
|
|
11
|
-
exports.default = ifAll;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = ifEquals;
|
|
3
4
|
function ifEquals(...args) {
|
|
4
5
|
if (args.length < 3) {
|
|
5
6
|
throw Error('At least two parameters must be provided');
|
|
@@ -8,4 +9,3 @@ function ifEquals(...args) {
|
|
|
8
9
|
const condition = args.every((item) => item === args[0]);
|
|
9
10
|
return condition ? options.fn(this) : options.inverse(this);
|
|
10
11
|
}
|
|
11
|
-
exports.default = ifEquals;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = ifEqualsSome;
|
|
3
4
|
function ifEqualsSome(...args) {
|
|
4
5
|
if (args.length < 4) {
|
|
5
6
|
throw Error('At least three parameters must be provided');
|
|
@@ -9,4 +10,3 @@ function ifEqualsSome(...args) {
|
|
|
9
10
|
const condition = args.some((item) => item === control);
|
|
10
11
|
return condition ? options.fn(this) : options.inverse(this);
|
|
11
12
|
}
|
|
12
|
-
exports.default = ifEqualsSome;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = ifSome;
|
|
3
4
|
function ifSome(...args) {
|
|
4
5
|
if (args.length < 2) {
|
|
5
6
|
throw Error('At least one parameter must be provided');
|
|
@@ -8,4 +9,3 @@ function ifSome(...args) {
|
|
|
8
9
|
const condition = args.some(Boolean);
|
|
9
10
|
return condition ? options.fn(this) : options.inverse(this);
|
|
10
11
|
}
|
|
11
|
-
exports.default = ifSome;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = json;
|
|
3
4
|
function json(...args) {
|
|
4
5
|
if (args.length !== 2) {
|
|
5
6
|
throw Error('Incorrect number of parameters provided');
|
|
@@ -13,4 +14,3 @@ function json(...args) {
|
|
|
13
14
|
}
|
|
14
15
|
return JSON.stringify(target);
|
|
15
16
|
}
|
|
16
|
-
exports.default = json;
|
|
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.default = renderReactComponent;
|
|
6
7
|
const path_1 = __importDefault(require("path"));
|
|
7
8
|
const react_1 = __importDefault(require("react"));
|
|
8
9
|
const server_1 = __importDefault(require("react-dom/server"));
|
|
@@ -30,4 +31,3 @@ function renderReactComponent({ hash }) {
|
|
|
30
31
|
// @ts-ignore
|
|
31
32
|
return server_1.default.renderToStaticMarkup(react_1.default.createElement(Component, props));
|
|
32
33
|
}
|
|
33
|
-
exports.default = renderReactComponent;
|
|
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.default = resize;
|
|
6
7
|
const querystring_1 = __importDefault(require("querystring"));
|
|
7
8
|
const host = 'https://www.ft.com/__origami/service/image/v2/images/raw';
|
|
8
9
|
const defaults = { source: 'next', fit: 'scale-down' };
|
|
@@ -16,4 +17,3 @@ function resize(...args) {
|
|
|
16
17
|
const query = querystring_1.default.stringify({ width, ...defaults, ...options.hash });
|
|
17
18
|
return `${host}/${encodeURIComponent(image)}?${query}`;
|
|
18
19
|
}
|
|
19
|
-
exports.default = resize;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = slice;
|
|
3
4
|
function slice(...args) {
|
|
4
5
|
if (args.length !== 2) {
|
|
5
6
|
throw Error('Incorrect number of parameters provided');
|
|
@@ -17,4 +18,3 @@ function slice(...args) {
|
|
|
17
18
|
});
|
|
18
19
|
return contents;
|
|
19
20
|
}
|
|
20
|
-
exports.default = slice;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = unlessAll;
|
|
3
4
|
function unlessAll(...args) {
|
|
4
5
|
if (args.length < 2) {
|
|
5
6
|
throw Error('At least one parameter must be provided');
|
|
@@ -8,4 +9,3 @@ function unlessAll(...args) {
|
|
|
8
9
|
const condition = args.some(Boolean) === false;
|
|
9
10
|
return condition ? options.fn(this) : options.inverse(this);
|
|
10
11
|
}
|
|
11
|
-
exports.default = unlessAll;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = unlessEquals;
|
|
3
4
|
function unlessEquals(...args) {
|
|
4
5
|
if (args.length < 3) {
|
|
5
6
|
throw Error('At least two parameters must be provided');
|
|
@@ -8,4 +9,3 @@ function unlessEquals(...args) {
|
|
|
8
9
|
const condition = args.every((item) => item === args[0]) === false;
|
|
9
10
|
return condition ? options.fn(this) : options.inverse(this);
|
|
10
11
|
}
|
|
11
|
-
exports.default = unlessEquals;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = unlessSome;
|
|
3
4
|
function unlessSome(...args) {
|
|
4
5
|
if (args.length < 2) {
|
|
5
6
|
throw Error('At least one parameter must be provided');
|
|
@@ -8,4 +9,3 @@ function unlessSome(...args) {
|
|
|
8
9
|
const condition = args.every(Boolean) === false;
|
|
9
10
|
return condition ? options.fn(this) : options.inverse(this);
|
|
10
11
|
}
|
|
11
|
-
exports.default = unlessSome;
|
package/dist/node/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -3,8 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.default = loadFileContents;
|
|
6
7
|
const fs_1 = __importDefault(require("fs"));
|
|
7
8
|
function loadFileContents(filePath) {
|
|
8
9
|
return fs_1.default.readFileSync(filePath).toString();
|
|
9
10
|
}
|
|
10
|
-
exports.default = loadFileContents;
|