@financial-times/dotcom-server-handlebars 9.0.0-beta.9 → 9.0.2
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/helpers/renderReactComponent.d.ts +1 -1
- package/dist/node/helpers/renderReactComponent.js +1 -0
- package/dist/node/helpers/slice.js +3 -0
- package/dist/node/helpers.js +20 -16
- package/dist/node/index.js +2 -2
- package/dist/tsconfig.tsbuildinfo +1977 -2231
- package/package.json +7 -5
- package/src/__test__/HandlebarsRenderer.spec.ts +12 -11
- package/src/helpers/renderReactComponent.ts +1 -0
- package/src/helpers/slice.ts +4 -0
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@financial-times/dotcom-server-handlebars",
|
|
3
|
-
"version": "9.0.
|
|
3
|
+
"version": "9.0.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/node/index.js",
|
|
6
|
-
"types": "
|
|
6
|
+
"types": "dist/node/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
9
9
|
"clean": "npm run clean:dist && npm run clean:node_modules",
|
|
@@ -22,9 +22,7 @@
|
|
|
22
22
|
"dateformat": "^3.0.3",
|
|
23
23
|
"glob": "^7.1.3",
|
|
24
24
|
"handlebars": "^4.3.1",
|
|
25
|
-
"mixin-deep": "^2.0.0"
|
|
26
|
-
"react": "^16.12.0",
|
|
27
|
-
"react-dom": "^16.12.0"
|
|
25
|
+
"mixin-deep": "^2.0.0"
|
|
28
26
|
},
|
|
29
27
|
"engines": {
|
|
30
28
|
"node": "16.x || 18.x",
|
|
@@ -45,5 +43,9 @@
|
|
|
45
43
|
},
|
|
46
44
|
"devDependencies": {
|
|
47
45
|
"check-engine": "^1.10.1"
|
|
46
|
+
},
|
|
47
|
+
"peerDependencies": {
|
|
48
|
+
"react": "17.x || 18.x",
|
|
49
|
+
"react-dom": "17.x || 18.x"
|
|
48
50
|
}
|
|
49
51
|
}
|
|
@@ -80,20 +80,21 @@ describe('dotcom-server-handlebars/src/PageKitHandlebars', () => {
|
|
|
80
80
|
})
|
|
81
81
|
|
|
82
82
|
describe('.renderView()', () => {
|
|
83
|
-
it('can render a template and fire a callback with the result', () => {
|
|
84
|
-
|
|
85
|
-
|
|
83
|
+
it('can render a template and fire a callback with the result', async () => {
|
|
84
|
+
const spy = jest.fn()
|
|
85
|
+
const templateContext = { title: 'Hello World', aside: 'Lorem ipsum' }
|
|
86
|
+
await instance.renderView(view, templateContext, spy)
|
|
86
87
|
|
|
87
|
-
|
|
88
|
-
|
|
88
|
+
const callbackParameters = spy.mock.calls[0]
|
|
89
|
+
const [callbackError, callbackSuccess] = callbackParameters
|
|
89
90
|
|
|
90
|
-
|
|
91
|
-
expect(result).toContain('<aside>Lorem ipsum</aside>')
|
|
92
|
-
expect(result).toMatch(/<main>.+<\/main>/s)
|
|
91
|
+
expect(spy).toHaveBeenCalledTimes(1)
|
|
93
92
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
93
|
+
expect(callbackError).toBeNull()
|
|
94
|
+
|
|
95
|
+
expect(callbackSuccess).toContain('<h1>Hello World</h1>')
|
|
96
|
+
expect(callbackSuccess).toContain('<aside>Lorem ipsum</aside>')
|
|
97
|
+
expect(callbackSuccess).toContain('<main>')
|
|
97
98
|
})
|
|
98
99
|
})
|
|
99
100
|
})
|
package/src/helpers/slice.ts
CHANGED
|
@@ -10,6 +10,10 @@ export default function slice(...args) {
|
|
|
10
10
|
const offset = parseInt(options.hash.offset, 10) || 0
|
|
11
11
|
const limit = parseInt(options.hash.limit, 10) || 1
|
|
12
12
|
|
|
13
|
+
if (!args[0]) {
|
|
14
|
+
return ''
|
|
15
|
+
}
|
|
16
|
+
|
|
13
17
|
const slicedItems = Array.from(args[0]).slice(offset, offset + limit)
|
|
14
18
|
|
|
15
19
|
let contents = ''
|