@newlogic-digital/core 0.9.13 → 0.9.14
Sign up to get free protection for your applications and to get access to all the features.
- package/modules/Templates.js +21 -12
- package/package.json +1 -1
package/modules/Templates.js
CHANGED
@@ -300,11 +300,11 @@ export class Templates {
|
|
300
300
|
(Twig) => {
|
301
301
|
Twig.exports.extendTag({
|
302
302
|
type: "json",
|
303
|
-
regex: /^json\s+(.+)$/,
|
303
|
+
regex: /^json\s+(.+)$|^json$/,
|
304
304
|
next: ["endjson"],
|
305
305
|
open: true,
|
306
306
|
compile: function (token) {
|
307
|
-
const expression = token.match[1]
|
307
|
+
const expression = token.match[1] ?? `'_null'`;
|
308
308
|
|
309
309
|
token.stack = Reflect.apply(Twig.expression.compile, this, [{
|
310
310
|
type: Twig.expression.type.expression,
|
@@ -318,17 +318,26 @@ export class Templates {
|
|
318
318
|
let name = Reflect.apply(Twig.expression.parse, this, [token.stack, context]);
|
319
319
|
let output = this.parse(token.output, context);
|
320
320
|
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
321
|
+
const minify = minifier.minify(output, {
|
322
|
+
collapseWhitespace: true,
|
323
|
+
collapseInlineTagWhitespace: false,
|
324
|
+
minifyCSS: true,
|
325
|
+
minifyJS: true
|
326
|
+
})
|
327
|
+
|
328
|
+
if (name === '_null') {
|
329
|
+
return {
|
330
|
+
chain: chain,
|
331
|
+
output: JSON.stringify(minify)
|
332
|
+
};
|
333
|
+
} else {
|
334
|
+
return {
|
335
|
+
chain: chain,
|
336
|
+
output: JSON.stringify({
|
337
|
+
[name]: minify
|
329
338
|
})
|
330
|
-
}
|
331
|
-
}
|
339
|
+
};
|
340
|
+
}
|
332
341
|
}
|
333
342
|
});
|
334
343
|
Twig.exports.extendTag({
|
package/package.json
CHANGED