@restorecommerce/handlebars-helperized 1.0.6 → 1.0.7
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/CHANGELOG.md +11 -0
- package/lib/helpers/custom-helpers.js +1 -1
- package/lib/helpers/custom-helpers.js.map +1 -0
- package/lib/helpers/l10n-helpers.js +1 -1
- package/lib/helpers/l10n-helpers.js.map +1 -0
- package/lib/helpers/moment-helpers.js +1 -0
- package/lib/helpers/moment-helpers.js.map +1 -0
- package/lib/helpers/numbro-helpers.js +1 -1
- package/lib/helpers/numbro-helpers.js.map +1 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.js +3 -1
- package/lib/index.js.map +1 -0
- package/package.json +6 -6
- package/tsconfig.json +12 -5
- package/src/helpers/custom-helpers.ts +0 -11
- package/src/helpers/l10n-helpers.ts +0 -20
- package/src/helpers/moment-helpers.ts +0 -64
- package/src/helpers/numbro-helpers.ts +0 -53
- package/src/index.ts +0 -80
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [1.0.7](https://github.com/restorecommerce/handlebars-helperized/compare/@restorecommerce/handlebars-helperized@1.0.6...@restorecommerce/handlebars-helperized@1.0.7) (2024-02-21)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* handlebars-helperized and mailer module ([ed596c4](https://github.com/restorecommerce/handlebars-helperized/commit/ed596c487c3d750c50ad0f628650317fc00920a3))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
## [1.0.6](https://github.com/restorecommerce/handlebars-helperized/compare/@restorecommerce/handlebars-helperized@1.0.5...@restorecommerce/handlebars-helperized@1.0.6) (2023-11-20)
|
|
7
18
|
|
|
8
19
|
**Note:** Version bump only for package @restorecommerce/handlebars-helperized
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
let customHandlebarsExtensions = (hbs, opts) => {
|
|
3
2
|
// increment a given numerical string by one
|
|
4
3
|
hbs.registerHelper('increment', (value, hash) => {
|
|
@@ -9,3 +8,4 @@ let customHandlebarsExtensions = (hbs, opts) => {
|
|
|
9
8
|
});
|
|
10
9
|
};
|
|
11
10
|
module.exports = customHandlebarsExtensions;
|
|
11
|
+
//# sourceMappingURL=custom-helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custom-helpers.js","sourceRoot":"","sources":["../../src/helpers/custom-helpers.ts"],"names":[],"mappings":"AACA,IAAI,0BAA0B,GAAG,CAAC,GAAQ,EAAE,IAAS,EAAE,EAAE;IACvD,4CAA4C;IAC5C,GAAG,CAAC,cAAc,CAAC,WAAW,EAAE,CAAC,KAAU,EAAE,IAAS,EAAE,EAAE;QACxD,MAAM,WAAW,GAAG,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACxC,IAAI,KAAK,CAAC,WAAW,CAAC;YAAE,OAAO,GAAG,CAAC;QACnC,OAAO,WAAW,GAAG,CAAC,CAAC;IACzB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,CAAC,OAAO,GAAG,0BAA0B,CAAC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
const tripleStache = /\{\{\{\s*(.*?)\s*\}\}\}/g;
|
|
3
2
|
const doubleStache = /\{\{\s*(.*?)\s*\}\}/g;
|
|
4
3
|
let localizationHandlebarsExtension = (hbs, opts) => {
|
|
@@ -18,3 +17,4 @@ let localizationHandlebarsExtension = (hbs, opts) => {
|
|
|
18
17
|
});
|
|
19
18
|
};
|
|
20
19
|
module.exports = localizationHandlebarsExtension;
|
|
20
|
+
//# sourceMappingURL=l10n-helpers.js.map
|
|
@@ -0,0 +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AAE,CAAC;QACtD,OAAO,IAAA,yBAAM,EAAC,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAC7C,CAAC,CAAC,CAAC;IAEH,sBAAsB;IACtB,sDAAsD;IACtD,kDAAkD;IAClD,qDAAqD;IACrD,4CAA4C;IAC5C,EAAE;IACF,sDAAsD;IACtD,mCAAmC;IACnC,GAAG,CAAC,cAAc,CAAC,KAAK,EAAE,CAAC,KAAU,EAAE,OAAY,EAAE,EAAE;QACrD,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,MAAM,IAAI,EAAE,CAAC;QACzC,MAAM,GAAG,GAAQ,yBAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QACxC,2BAA2B;QAC3B,OAAO,IAAA,yBAAM,EAAC,GAAG,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAC1C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,CAAC,OAAO,GAAG,yBAAyB,CAAC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
const numbro = require('numbro');
|
|
3
2
|
const allLanguages = require('numbro/dist/languages.min');
|
|
4
3
|
Object.values(allLanguages).forEach((data) => {
|
|
@@ -45,3 +44,4 @@ let numbroHandlebarsExtension = (hbs, opts) => {
|
|
|
45
44
|
});
|
|
46
45
|
};
|
|
47
46
|
module.exports = numbroHandlebarsExtension;
|
|
47
|
+
//# sourceMappingURL=numbro-helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"numbro-helpers.js","sourceRoot":"","sources":["../../src/helpers/numbro-helpers.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AACjC,MAAM,YAAY,GAAG,OAAO,CAAC,2BAA2B,CAAC,CAAC;AAE1D,MAAM,CAAC,MAAM,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CAAC,CAAC,CAAC;IAEH,gCAAgC;IAChC,GAAG,CAAC,cAAc,CAAC,KAAK,EAAE,CAAC,KAAU,EAAE,IAAS,EAAE,EAAE;QAClD,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;QAC3B,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC;YAC1B,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,QAAQ;SACf,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,CAAC,OAAO,GAAG,yBAAyB,CAAC"}
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -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.Renderer = void 0;
|
|
6
7
|
const juice_1 = __importDefault(require("juice"));
|
|
7
8
|
const defaults_1 = __importDefault(require("lodash/defaults"));
|
|
8
9
|
const defaultOpts = {
|
|
@@ -62,4 +63,5 @@ class Renderer {
|
|
|
62
63
|
return html;
|
|
63
64
|
}
|
|
64
65
|
}
|
|
65
|
-
exports.
|
|
66
|
+
exports.Renderer = Renderer;
|
|
67
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,+DAAuC;AAEvC,MAAM,WAAW,GAAG;IAClB,MAAM,EAAE,OAAO;IACf,KAAK,EAAE,EAAE;CACV,CAAC;AAEF,0DAA0D;AAC1D,MAAM,IAAI,GAAG,CAAC,OAA2B,EAAE,iBAAsB,EAAE,EAAE;IACnE,kCAAkC;IAClC,MAAM,IAAI,GAAG,IAAA,kBAAQ,EAAC,OAAO,EAA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CAAC,CAAC;IAC7C,CAAC;IAED;;;MAGE;IACF,MAAM,CAAC,OAAe;QACpB,IAAI,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QAElC,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YACf,IAAI,GAAG,eAAK,CAAC,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,EAAE;gBAC3C,oBAAoB,EAAE,IAAI;gBAC1B,iBAAiB,EAAE,IAAI;gBACvB,oBAAoB,EAAE,IAAI;gBAC1B,iBAAiB,EAAE,IAAI;gBACvB,oBAAoB,EAAE,IAAI;gBAC1B,qBAAqB,EAAE,IAAI;gBAC3B,uBAAuB,EAAE,IAAI;gBAC7B,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,sCAAsC;aAC5D,CAAC,CAAC;QACL,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAEQ,4BAAQ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@restorecommerce/handlebars-helperized",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"description": "Opinionated handlebars based templating engine for rendering e-mail like content",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"handlebars": "^4.7.8",
|
|
23
23
|
"handlebars-layouts": "^3.1.4",
|
|
24
|
-
"juice": "^
|
|
24
|
+
"juice": "^10.0.0",
|
|
25
25
|
"lodash.defaults": "4.2.0",
|
|
26
|
-
"moment-timezone": "^0.5.
|
|
26
|
+
"moment-timezone": "^0.5.45",
|
|
27
27
|
"numbro": "^2.4.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"lint": "eslint src --ext .ts ",
|
|
49
49
|
"pretest": "npm run build",
|
|
50
50
|
"test": "nyc mocha ./test/* --exit",
|
|
51
|
-
"build:tsc": "tsc
|
|
51
|
+
"build:tsc": "tsc -d",
|
|
52
52
|
"build:clean": "rimraf lib",
|
|
53
53
|
"build": "npm-run-all lint build:clean build:tsc",
|
|
54
54
|
"lcov-report": "nyc report --reporter=lcov",
|
|
@@ -61,10 +61,10 @@
|
|
|
61
61
|
"targets": {
|
|
62
62
|
"build": {
|
|
63
63
|
"outputs": [
|
|
64
|
-
"
|
|
64
|
+
"{projectRoot}/lib"
|
|
65
65
|
]
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
},
|
|
69
|
-
"gitHead": "
|
|
69
|
+
"gitHead": "fa959facd4396dfa00a2c388d00a504d350e0190"
|
|
70
70
|
}
|
package/tsconfig.json
CHANGED
|
@@ -1,25 +1,32 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
|
-
"target": "
|
|
3
|
+
"target": "ES2021",
|
|
4
4
|
"module": "commonjs",
|
|
5
5
|
"moduleResolution": "node",
|
|
6
|
+
"declaration": true,
|
|
7
|
+
// "strict": true,
|
|
6
8
|
"emitDecoratorMetadata": true,
|
|
7
9
|
"experimentalDecorators": true,
|
|
8
10
|
"allowSyntheticDefaultImports": true,
|
|
9
|
-
"
|
|
10
|
-
"esModuleInterop": true,
|
|
11
|
+
"noUnusedLocals": false,
|
|
11
12
|
"skipLibCheck": true,
|
|
13
|
+
"esModuleInterop": true,
|
|
14
|
+
"sourceMap": true,
|
|
12
15
|
"outDir": "lib",
|
|
13
16
|
"typeRoots": [
|
|
14
17
|
"node_modules/@types"
|
|
15
18
|
],
|
|
19
|
+
"lib": [
|
|
20
|
+
"es2020.promise",
|
|
21
|
+
"dom"
|
|
22
|
+
]
|
|
16
23
|
},
|
|
17
24
|
"include": [
|
|
18
|
-
"src/**/*.ts"
|
|
25
|
+
"./src/**/*.ts"
|
|
19
26
|
],
|
|
20
27
|
"exclude": [
|
|
21
28
|
"node_modules",
|
|
22
29
|
"lib",
|
|
23
30
|
"doc"
|
|
24
31
|
]
|
|
25
|
-
}
|
|
32
|
+
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
let customHandlebarsExtensions = (hbs: any, opts: any) => {
|
|
3
|
-
// increment a given numerical string by one
|
|
4
|
-
hbs.registerHelper('increment', (value: any, hash: any) => {
|
|
5
|
-
const toIncrement = parseInt(value, 10);
|
|
6
|
-
if (isNaN(toIncrement)) return '0';
|
|
7
|
-
return toIncrement + 1;
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
module.exports = customHandlebarsExtensions;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
const tripleStache = /\{\{\{\s*(.*?)\s*\}\}\}/g;
|
|
2
|
-
const doubleStache = /\{\{\s*(.*?)\s*\}\}/g;
|
|
3
|
-
|
|
4
|
-
let localizationHandlebarsExtension = (hbs: any, opts: any) => {
|
|
5
|
-
hbs.registerHelper('t', (key: string, hash = {} as any) => {
|
|
6
|
-
const locale = opts.locale;
|
|
7
|
-
let result = opts.texts[key] || key;
|
|
8
|
-
result = (typeof result === 'object') ? result[locale] : result;
|
|
9
|
-
if (!result) return 'Missing translation for ' + key;
|
|
10
|
-
const data = hash.data.root;
|
|
11
|
-
return result.replace(doubleStache, (i: any, match: any) => {
|
|
12
|
-
return data[match] ? data[match] : ('{{' + match + '}}');
|
|
13
|
-
}).replace(tripleStache, (i: any, match: any) => {
|
|
14
|
-
// TODO: escaping
|
|
15
|
-
return data[match] ? data[match] : ('{{{' + match + '}}}');
|
|
16
|
-
});
|
|
17
|
-
});
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
module.exports = localizationHandlebarsExtension;
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import moment from 'moment-timezone';
|
|
2
|
-
|
|
3
|
-
let momentHandlebarsExtension = (hbs: any, opts: any) => {
|
|
4
|
-
// Output point in time relative to current point in time
|
|
5
|
-
// for example: '1h ago'
|
|
6
|
-
hbs.registerHelper('ago', (value: any, options: any) => {
|
|
7
|
-
let v = value;
|
|
8
|
-
if (options.isSeconds) {
|
|
9
|
-
// the given property represents seconds since UNIX epoch, so we
|
|
10
|
-
// multiply by 1000 to get the date in milliseconds since UNIX epoch
|
|
11
|
-
v *= 1000;
|
|
12
|
-
}
|
|
13
|
-
const tz = options.hash.timezone || moment.tz.guess();
|
|
14
|
-
return moment.tz(v, tz).locale(opts.locale).fromNow();
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
// Date format short
|
|
18
|
-
hbs.registerHelper('df', (value: any, options: any) => {
|
|
19
|
-
const tz = options.hash.timezone || moment.tz.guess();
|
|
20
|
-
return moment.tz(value, tz).locale(opts.locale).format('L');
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
// Date format Long
|
|
24
|
-
hbs.registerHelper('dfl', (value: any, options: any) => {
|
|
25
|
-
const tz = options.hash.timezone || moment.tz.guess();
|
|
26
|
-
return moment.tz(value, tz).locale(opts.locale).format('LL');
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
// Time format
|
|
30
|
-
hbs.registerHelper('tf', (value: any, options: any) => {
|
|
31
|
-
const tz = options.hash.timezone || moment.tz.guess();
|
|
32
|
-
return moment.tz(value, tz).locale(opts.locale).format('LT');
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
// Date-Time format
|
|
36
|
-
hbs.registerHelper('dtf', (value: any, options: any) => {
|
|
37
|
-
const tz = options.hash.timezone || moment.tz.guess();
|
|
38
|
-
return moment.tz(value, tz).locale(opts.locale).format('LLL');
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
// Date-Time format with given format
|
|
42
|
-
hbs.registerHelper('dff', (value: any, options: any) => {
|
|
43
|
-
const format = options.hash.format || '';
|
|
44
|
-
const tz = options.hash.timezone || moment.tz.guess();
|
|
45
|
-
return moment(value).tz(tz).format(format);
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
// Duration formatting
|
|
49
|
-
// Warning, localization should not be used with this:
|
|
50
|
-
// While the pattern `D` yields the number of days
|
|
51
|
-
// `dddd` would yield to a name of a weekday which is
|
|
52
|
-
// of course not applicapble for a duration.
|
|
53
|
-
//
|
|
54
|
-
// A format can be a template string with this syntax:
|
|
55
|
-
// '[it\'s] D [days and] h [hours]'
|
|
56
|
-
hbs.registerHelper('duf', (value: any, options: any) => {
|
|
57
|
-
const format = options.hash.format || '';
|
|
58
|
-
const dur: any = moment.duration(value);
|
|
59
|
-
// eslint-disable-next-line
|
|
60
|
-
return moment(dur._data).format(format);
|
|
61
|
-
});
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
module.exports = momentHandlebarsExtension;
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
const numbro = require('numbro');
|
|
2
|
-
const allLanguages = require('numbro/dist/languages.min');
|
|
3
|
-
|
|
4
|
-
Object.values(allLanguages).forEach((data) => {
|
|
5
|
-
numbro.registerLanguage(data);
|
|
6
|
-
});
|
|
7
|
-
|
|
8
|
-
let numbroHandlebarsExtension = (hbs: any, opts: any) => {
|
|
9
|
-
const locale = opts.locale.replace('_', '-');
|
|
10
|
-
|
|
11
|
-
// For numeric values without decimals
|
|
12
|
-
hbs.registerHelper('nfn', (value: any, hash: any) => {
|
|
13
|
-
numbro.setLanguage(locale);
|
|
14
|
-
return numbro(value).format({
|
|
15
|
-
thousandSeparated: true,
|
|
16
|
-
mantissa: 0
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
// For currency based numeric values
|
|
21
|
-
hbs.registerHelper('nfc', (value: any, hash: any) => {
|
|
22
|
-
const lhash = hash.hash;
|
|
23
|
-
numbro.setLanguage(locale);
|
|
24
|
-
// Don't use formatCurrency as it does not allow control over the currency
|
|
25
|
-
// symbol in confunction with locales
|
|
26
|
-
|
|
27
|
-
let formatted = numbro(value).format({
|
|
28
|
-
mantissa: 2,
|
|
29
|
-
thousandSeparated: true
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
const cs = lhash.cs;
|
|
33
|
-
if (cs === undefined) return formatted;
|
|
34
|
-
|
|
35
|
-
if (lhash.csPos === 'postfix') {
|
|
36
|
-
formatted += cs;
|
|
37
|
-
} else {
|
|
38
|
-
formatted = cs + formatted;
|
|
39
|
-
}
|
|
40
|
-
return formatted;
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
// For byte based numeric values
|
|
44
|
-
hbs.registerHelper('nfb', (value: any, hash: any) => {
|
|
45
|
-
numbro.setLanguage(locale);
|
|
46
|
-
return numbro(value).format({
|
|
47
|
-
output: 'byte',
|
|
48
|
-
base: 'binary'
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
module.exports = numbroHandlebarsExtension;
|
package/src/index.ts
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import juice from 'juice';
|
|
2
|
-
import defaults from 'lodash/defaults';
|
|
3
|
-
|
|
4
|
-
const defaultOpts = {
|
|
5
|
-
locale: 'en_US',
|
|
6
|
-
texts: {}
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
// Initializes and configures a custom handlebars instance
|
|
10
|
-
const init = (options: object | undefined, customHelpersList: any) => {
|
|
11
|
-
// default values if nothing given
|
|
12
|
-
const opts = defaults(options, defaultOpts);
|
|
13
|
-
// the basic building block is the handlebars rendering engine
|
|
14
|
-
const hbs = require('handlebars');
|
|
15
|
-
// more functionality directly added via custom plugins from ./lib
|
|
16
|
-
require('./helpers/l10n-helpers.js')(hbs, opts); // localization
|
|
17
|
-
require('./helpers/numbro-helpers.js')(hbs, opts); // numbers & currencies
|
|
18
|
-
require('./helpers/moment-helpers.js')(hbs, opts); // dates, times & durations
|
|
19
|
-
require('./helpers/custom-helpers.js')(hbs, opts); // everything else
|
|
20
|
-
|
|
21
|
-
// add custom helpers from rendering-srv
|
|
22
|
-
if (customHelpersList) {
|
|
23
|
-
for (let customHelper of customHelpersList) {
|
|
24
|
-
const filePath = customHelper;
|
|
25
|
-
require(filePath)(hbs, opts);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
// extend rendering with layout functionality
|
|
29
|
-
const handlebarsLayouts = require('handlebars-layouts');
|
|
30
|
-
handlebarsLayouts.register(hbs);
|
|
31
|
-
return hbs;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
class Renderer {
|
|
35
|
-
/**
|
|
36
|
-
@param {String} template the template
|
|
37
|
-
@param {String} layout the optional layout
|
|
38
|
-
@param {String} style the style
|
|
39
|
-
@param {Object} opts handlebars options
|
|
40
|
-
@param {Array} customHelpersList contains a list of custom helpers (optional)
|
|
41
|
-
*/
|
|
42
|
-
|
|
43
|
-
hbs: any;
|
|
44
|
-
style: string | undefined;
|
|
45
|
-
template: any;
|
|
46
|
-
|
|
47
|
-
constructor(template: string, layout?: string | undefined, style?: string | undefined, opts?: object | undefined, customHelpersList?: any) {
|
|
48
|
-
this.hbs = init(opts, customHelpersList);
|
|
49
|
-
this.style = style;
|
|
50
|
-
if (layout) {
|
|
51
|
-
this.hbs.registerPartial('layout', layout);
|
|
52
|
-
}
|
|
53
|
-
this.template = this.hbs.compile(template);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
@param {Object} context: required data for the placeholders
|
|
58
|
-
@return {String} html
|
|
59
|
-
*/
|
|
60
|
-
render(context: Object) {
|
|
61
|
-
let html = this.template(context);
|
|
62
|
-
|
|
63
|
-
if (this.style) {
|
|
64
|
-
html = juice.inlineContent(html, this.style, {
|
|
65
|
-
inlinePseudoElements: true,
|
|
66
|
-
preserveImportant: true,
|
|
67
|
-
preserveMediaQueries: true,
|
|
68
|
-
preserveFontFaces: true,
|
|
69
|
-
applyWidthAttributes: true,
|
|
70
|
-
applyHeightAttributes: true,
|
|
71
|
-
insertPreservedExtraCss: true,
|
|
72
|
-
extraCss: this.style // to enable inlining of media queries
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
return html;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export default Renderer;
|