express-hbs 2.4.0 → 2.4.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/.github/workflows/test.yml +5 -5
- package/LICENSE +1 -1
- package/README.md +1 -1
- package/lib/resolver.js +20 -6
- package/package.json +8 -9
|
@@ -3,20 +3,20 @@ on:
|
|
|
3
3
|
pull_request:
|
|
4
4
|
push:
|
|
5
5
|
branches:
|
|
6
|
-
-
|
|
6
|
+
- main
|
|
7
7
|
- 'renovate/*'
|
|
8
8
|
|
|
9
9
|
jobs:
|
|
10
10
|
build:
|
|
11
|
-
runs-on: ubuntu-
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
12
|
if: github.event_name == 'push' || (github.event_name == 'pull_request' && !startsWith(github.head_ref, 'renovate/'))
|
|
13
13
|
strategy:
|
|
14
14
|
matrix:
|
|
15
|
-
node: [
|
|
15
|
+
node: [ 14, 16, 18 ]
|
|
16
16
|
name: Node ${{ matrix.node }}
|
|
17
17
|
steps:
|
|
18
|
-
- uses: actions/checkout@
|
|
19
|
-
- uses: actions/setup-node@
|
|
18
|
+
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
|
|
19
|
+
- uses: actions/setup-node@v3
|
|
20
20
|
with:
|
|
21
21
|
node-version: ${{ matrix.node }}
|
|
22
22
|
- run: yarn
|
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
The MIT License (MIT)
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2012-
|
|
3
|
+
Copyright (c) 2012-2023 Barc, Inc., Ghost Foundation
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
6
6
|
this software and associated documentation files (the "Software"), to deal in
|
package/README.md
CHANGED
|
@@ -301,4 +301,4 @@ Big thanks to all [CONTRIBUTORS](https://github.com/TryGhost/express-hbs/contrib
|
|
|
301
301
|
|
|
302
302
|
The MIT License (MIT)
|
|
303
303
|
|
|
304
|
-
Copyright (c) 2012-
|
|
304
|
+
Copyright (c) 2012-2023 Barc, Inc., Ghost Foundation - Released under the [MIT license](LICENSE).
|
package/lib/resolver.js
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var Promise = require('bluebird');
|
|
4
|
-
|
|
5
3
|
var generateId = require('./generate-id');
|
|
6
4
|
|
|
7
5
|
var ID_LENGTH = 8;
|
|
8
|
-
var ID_PREFIX = '
|
|
6
|
+
var ID_PREFIX = '__aSyNcId__';
|
|
7
|
+
|
|
8
|
+
// NOTE: We must include a character which is escaped by Handlebars in the "async id"
|
|
9
|
+
// This is so that when using an async helper "inline", such as {{asyncHelper "foo"}}
|
|
10
|
+
// the content is correctly escaped depending on whether double or triple braces.
|
|
11
|
+
var ID_ESCAPED_STRING = '<_';
|
|
12
|
+
|
|
9
13
|
var ID_SUFFIX = '__';
|
|
10
14
|
|
|
11
15
|
function resolve(cache, fn, context) {
|
|
12
|
-
var id = ID_PREFIX + generateId(ID_LENGTH) + ID_SUFFIX;
|
|
16
|
+
var id = ID_PREFIX + ID_ESCAPED_STRING + generateId(ID_LENGTH) + ID_SUFFIX;
|
|
13
17
|
cache[id] = new Promise(function(passed, failed) {
|
|
14
18
|
try {
|
|
15
19
|
fn(context, function(res) {
|
|
@@ -22,15 +26,25 @@ function resolve(cache, fn, context) {
|
|
|
22
26
|
return id;
|
|
23
27
|
}
|
|
24
28
|
|
|
29
|
+
// cache is an object where the keys are cache keys and values are promises. See above.
|
|
25
30
|
function done(cache, callback) {
|
|
26
|
-
Promise.
|
|
27
|
-
|
|
31
|
+
return Promise.all(Object.values(cache))
|
|
32
|
+
.then(function(values) {
|
|
33
|
+
var resolvedCache = {};
|
|
34
|
+
var keys = Object.keys(cache);
|
|
35
|
+
values.forEach(function(value, index) {
|
|
36
|
+
resolvedCache[keys[index]] = value;
|
|
37
|
+
});
|
|
38
|
+
callback(null, resolvedCache);
|
|
28
39
|
}).catch(function(error) {
|
|
29
40
|
callback(error);
|
|
30
41
|
});
|
|
31
42
|
}
|
|
32
43
|
|
|
33
44
|
function hasResolvers(text) {
|
|
45
|
+
// NOTE: We specifically search the text for the ID_PREFIX **NOT** including the escapable character
|
|
46
|
+
// This is because that character can be escaped in the text, and lead us to not finding unresolved
|
|
47
|
+
// async helper outputs.
|
|
34
48
|
if (text.search(ID_PREFIX) > 0) {
|
|
35
49
|
return true;
|
|
36
50
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "express-hbs",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.2",
|
|
4
4
|
"description": "Express handlebars template engine complete with multiple layouts, partials and blocks.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"express4",
|
|
@@ -29,17 +29,16 @@
|
|
|
29
29
|
"author": "Mario Gutierrez <mario@barc.com>",
|
|
30
30
|
"license": "MIT",
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"cookie-parser": "1.4.
|
|
33
|
-
"eslint": "
|
|
34
|
-
"express": "4.
|
|
35
|
-
"i18n": "0.
|
|
36
|
-
"mocha": "
|
|
32
|
+
"cookie-parser": "1.4.6",
|
|
33
|
+
"eslint": "8.48.0",
|
|
34
|
+
"express": "4.18.2",
|
|
35
|
+
"i18n": "0.15.1",
|
|
36
|
+
"mocha": "10.2.0",
|
|
37
37
|
"nyc": "15.1.0",
|
|
38
|
-
"rewire": "
|
|
39
|
-
"supertest": "6.
|
|
38
|
+
"rewire": "7.0.0",
|
|
39
|
+
"supertest": "6.3.3"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"bluebird": "^3.5.3",
|
|
43
42
|
"handlebars": "^4.7.7",
|
|
44
43
|
"lodash": "^4.17.21",
|
|
45
44
|
"readdirp": "^3.6.0"
|