@evlop/commons 1.0.144 → 1.0.145
Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useTemplate.d.ts","sourceRoot":"","sources":["../../../src/hooks/useTemplate.tsx"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"useTemplate.d.ts","sourceRoot":"","sources":["../../../src/hooks/useTemplate.tsx"],"names":[],"mappings":"AAcA,eAAO,MAAM,WAAW,oBAAqB,MAAM,QAqBlD,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
@@ -6,13 +6,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.useTemplate = void 0;
|
7
7
|
const react_1 = require("react");
|
8
8
|
const useScope_1 = require("./useScope");
|
9
|
+
const lodash_1 = require("lodash");
|
10
|
+
const uuid_1 = require("uuid");
|
9
11
|
const handlebars_min_js_1 = __importDefault(require("handlebars/dist/handlebars.min.js"));
|
12
|
+
const handlebarsCompile = lodash_1.memoize((stringValue) => handlebars_min_js_1.default.compile(stringValue, { noEscape: true }), (stringValue) => {
|
13
|
+
if (lodash_1.size(stringValue) < 100)
|
14
|
+
return stringValue;
|
15
|
+
return uuid_1.v5(stringValue, '060c30f4-309d-4054-a62e-7d7390c63cce');
|
16
|
+
});
|
10
17
|
const useTemplate = (templateString) => {
|
11
18
|
const scope = useScope_1.useScope();
|
12
19
|
const applyTemplate = react_1.useCallback((stringValue) => {
|
13
20
|
if (stringValue !== undefined && typeof stringValue === "string") {
|
14
21
|
try {
|
15
|
-
const template =
|
22
|
+
const template = handlebarsCompile(stringValue);
|
16
23
|
return template(scope, { allowProtoMethodsByDefault: true, allowProtoPropertiesByDefault: true });
|
17
24
|
}
|
18
25
|
catch (e) { }
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useTemplate.js","sourceRoot":"","sources":["../../../src/hooks/useTemplate.tsx"],"names":[],"mappings":";;;;;;AAAA,iCAA2C;AAC3C,yCAAoC;AACpC,0FAA2D;
|
1
|
+
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