@bookshop/hugo-engine 2.4.0-hugo.3 → 2.4.0-hugo.4
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/.nyc_output/{05cdaf09-20ac-4f20-a9c6-2b88c3a0faf2.json → 5ff8dc15-11f5-4e63-9582-916657a3e8ba.json} +0 -0
- package/.nyc_output/{6e19d05c-cf57-446d-a6c8-7daaaf0e7db6.json → 7054beca-6b99-4dd2-a8c7-4aec983815fe.json} +0 -0
- package/.nyc_output/{7f3f24c5-d070-4832-a421-c10f43bb42c3.json → 727fa7a6-f028-4392-b4d1-0b0ec68f3077.json} +0 -0
- package/.nyc_output/{aa72646f-c2f6-4103-b57f-22eacd776b6f.json → 7e79dc9e-2fd1-45e0-8a5a-d743898cb2ab.json} +0 -0
- package/.nyc_output/{c924a9c2-577c-44b7-9c5c-b515d364fc95.json → a528b45c-4264-43cd-bf2c-ace2d3f3528d.json} +0 -0
- package/.nyc_output/processinfo/5ff8dc15-11f5-4e63-9582-916657a3e8ba.json +1 -0
- package/.nyc_output/processinfo/7054beca-6b99-4dd2-a8c7-4aec983815fe.json +1 -0
- package/.nyc_output/processinfo/727fa7a6-f028-4392-b4d1-0b0ec68f3077.json +1 -0
- package/.nyc_output/processinfo/7e79dc9e-2fd1-45e0-8a5a-d743898cb2ab.json +1 -0
- package/.nyc_output/processinfo/a528b45c-4264-43cd-bf2c-ace2d3f3528d.json +1 -0
- package/.nyc_output/processinfo/index.json +1 -1
- package/lib/hugoIdentifierParser.js +7 -1
- package/lib/hugoIdentifierParser.test.js +21 -2
- package/lib/translateTextTemplate.js +7 -0
- package/lib/translateTextTemplate.test.js +11 -0
- package/package.json +2 -2
- package/.nyc_output/processinfo/05cdaf09-20ac-4f20-a9c6-2b88c3a0faf2.json +0 -1
- package/.nyc_output/processinfo/6e19d05c-cf57-446d-a6c8-7daaaf0e7db6.json +0 -1
- package/.nyc_output/processinfo/7f3f24c5-d070-4832-a421-c10f43bb42c3.json +0 -1
- package/.nyc_output/processinfo/aa72646f-c2f6-4103-b57f-22eacd776b6f.json +0 -1
- package/.nyc_output/processinfo/c924a9c2-577c-44b7-9c5c-b515d364fc95.json +0 -1
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"parent":null,"pid":64953,"argv":["/Users/liambigelow/.nvm/versions/node/v14.16.0/bin/node","/Users/liambigelow/Projects/CC/bookshop/javascript-modules/node_modules/ava/cli.js","-v"],"execArgv":[],"cwd":"/Users/liambigelow/Projects/CC/bookshop/javascript-modules/engines/hugo-engine","time":1643573514056,"ppid":64952,"coverageFilename":"/Users/liambigelow/Projects/CC/bookshop/javascript-modules/engines/hugo-engine/.nyc_output/5ff8dc15-11f5-4e63-9582-916657a3e8ba.json","externalId":"","uuid":"5ff8dc15-11f5-4e63-9582-916657a3e8ba","files":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"parent":"5ff8dc15-11f5-4e63-9582-916657a3e8ba","pid":64957,"argv":["/Users/liambigelow/.nvm/versions/node/v14.16.0/bin/node","/Users/liambigelow/Projects/CC/bookshop/javascript-modules/node_modules/ava/lib/worker/subprocess.js"],"execArgv":[],"cwd":"/Users/liambigelow/Projects/CC/bookshop/javascript-modules/engines/hugo-engine","time":1643573514565,"ppid":64953,"coverageFilename":"/Users/liambigelow/Projects/CC/bookshop/javascript-modules/engines/hugo-engine/.nyc_output/7054beca-6b99-4dd2-a8c7-4aec983815fe.json","externalId":"","uuid":"7054beca-6b99-4dd2-a8c7-4aec983815fe","files":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"parent":"5ff8dc15-11f5-4e63-9582-916657a3e8ba","pid":64955,"argv":["/Users/liambigelow/.nvm/versions/node/v14.16.0/bin/node","/Users/liambigelow/Projects/CC/bookshop/javascript-modules/node_modules/ava/lib/worker/subprocess.js"],"execArgv":[],"cwd":"/Users/liambigelow/Projects/CC/bookshop/javascript-modules/engines/hugo-engine","time":1643573514552,"ppid":64953,"coverageFilename":"/Users/liambigelow/Projects/CC/bookshop/javascript-modules/engines/hugo-engine/.nyc_output/727fa7a6-f028-4392-b4d1-0b0ec68f3077.json","externalId":"","uuid":"727fa7a6-f028-4392-b4d1-0b0ec68f3077","files":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"parent":"5ff8dc15-11f5-4e63-9582-916657a3e8ba","pid":64956,"argv":["/Users/liambigelow/.nvm/versions/node/v14.16.0/bin/node","/Users/liambigelow/Projects/CC/bookshop/javascript-modules/node_modules/ava/lib/worker/subprocess.js"],"execArgv":[],"cwd":"/Users/liambigelow/Projects/CC/bookshop/javascript-modules/engines/hugo-engine","time":1643573514562,"ppid":64953,"coverageFilename":"/Users/liambigelow/Projects/CC/bookshop/javascript-modules/engines/hugo-engine/.nyc_output/7e79dc9e-2fd1-45e0-8a5a-d743898cb2ab.json","externalId":"","uuid":"7e79dc9e-2fd1-45e0-8a5a-d743898cb2ab","files":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"parent":"5ff8dc15-11f5-4e63-9582-916657a3e8ba","pid":64954,"argv":["/Users/liambigelow/.nvm/versions/node/v14.16.0/bin/node","/Users/liambigelow/Projects/CC/bookshop/javascript-modules/node_modules/ava/lib/worker/subprocess.js"],"execArgv":[],"cwd":"/Users/liambigelow/Projects/CC/bookshop/javascript-modules/engines/hugo-engine","time":1643573514548,"ppid":64953,"coverageFilename":"/Users/liambigelow/Projects/CC/bookshop/javascript-modules/engines/hugo-engine/.nyc_output/a528b45c-4264-43cd-bf2c-ace2d3f3528d.json","externalId":"","uuid":"a528b45c-4264-43cd-bf2c-ace2d3f3528d","files":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"processes":{"
|
|
1
|
+
{"processes":{"5ff8dc15-11f5-4e63-9582-916657a3e8ba":{"parent":null,"children":["7054beca-6b99-4dd2-a8c7-4aec983815fe","727fa7a6-f028-4392-b4d1-0b0ec68f3077","7e79dc9e-2fd1-45e0-8a5a-d743898cb2ab","a528b45c-4264-43cd-bf2c-ace2d3f3528d"]},"7054beca-6b99-4dd2-a8c7-4aec983815fe":{"parent":"5ff8dc15-11f5-4e63-9582-916657a3e8ba","children":[]},"727fa7a6-f028-4392-b4d1-0b0ec68f3077":{"parent":"5ff8dc15-11f5-4e63-9582-916657a3e8ba","children":[]},"7e79dc9e-2fd1-45e0-8a5a-d743898cb2ab":{"parent":"5ff8dc15-11f5-4e63-9582-916657a3e8ba","children":[]},"a528b45c-4264-43cd-bf2c-ace2d3f3528d":{"parent":"5ff8dc15-11f5-4e63-9582-916657a3e8ba","children":[]}},"files":{},"externalIds":{}}
|
|
@@ -22,6 +22,13 @@ export class IdentifierParser {
|
|
|
22
22
|
|
|
23
23
|
// Some short-circuits for easy to regex patterns to skip the parser
|
|
24
24
|
tryShortCircuit() {
|
|
25
|
+
// change an index of . to be only the index
|
|
26
|
+
const indexDotFunc = /^\s*\(\s*index\s+(?:\(\s*\.\s*\)|\.)\s+(\d+)\s*\)\s*$/
|
|
27
|
+
if (indexDotFunc.test(this.input)) {
|
|
28
|
+
const [, index] = this.input.match(indexDotFunc);
|
|
29
|
+
return `${index}`;
|
|
30
|
+
}
|
|
31
|
+
|
|
25
32
|
// change the index function into Bookshop dot notation
|
|
26
33
|
const indexFunc = /^\s*\(\s*index\s+\(?\.?(.+?)\)?\s+(\d+)\s*\)\s*$/
|
|
27
34
|
if (indexFunc.test(this.input)) {
|
|
@@ -30,7 +37,6 @@ export class IdentifierParser {
|
|
|
30
37
|
}
|
|
31
38
|
|
|
32
39
|
// strip the leading . from basic variable references
|
|
33
|
-
const variableDot = /^\s*\.([^\.\s])/;
|
|
34
40
|
if (/^\s*\./.test(this.input)) {
|
|
35
41
|
return this.input.replace(/^\s*\.([^\.\s])/, '$1');
|
|
36
42
|
}
|
|
@@ -66,7 +66,26 @@ test(`Nested dicts and slices`, async t => {
|
|
|
66
66
|
});
|
|
67
67
|
|
|
68
68
|
test(`Converts an index into dot notation`, async t => {
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
let ident = `(index (.items) 5)`;
|
|
70
|
+
let output = (new IdentifierParser(ident)).build();
|
|
71
71
|
t.deepEqual(output, `items.5`);
|
|
72
|
+
|
|
73
|
+
ident = `(index .array 5)`;
|
|
74
|
+
output = (new IdentifierParser(ident)).build();
|
|
75
|
+
t.deepEqual(output, `array.5`);
|
|
76
|
+
|
|
77
|
+
ident = `(index $variable 5)`;
|
|
78
|
+
output = (new IdentifierParser(ident)).build();
|
|
79
|
+
t.deepEqual(output, `$variable.5`);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
test(`Converts a dot index into a JS object property`, async t => {
|
|
84
|
+
let ident = `(index (.) 5)`;
|
|
85
|
+
let output = (new IdentifierParser(ident)).build();
|
|
86
|
+
t.deepEqual(output, `5`);
|
|
87
|
+
|
|
88
|
+
ident = `(index . 1234)`;
|
|
89
|
+
output = (new IdentifierParser(ident)).build();
|
|
90
|
+
t.deepEqual(output, `1234`);
|
|
72
91
|
});
|
|
@@ -8,6 +8,7 @@ const tokens = {
|
|
|
8
8
|
ASSIGN: /{{\s*(\$\S+)\s+:=\s+(.+?)\s*}}/,
|
|
9
9
|
WITH: /{{\s*with\s+(.+?)\s*}}/,
|
|
10
10
|
BOOKSHOP: /{{\s*partial\s+"bookshop(?:_partial)?"\s+\(\s*slice\s+"(.+?)" (.+?)\s*\)\s*}}/,
|
|
11
|
+
BOOKSHOP_SCOPED: /{{\s*partial\s+"bookshop(?:_partial)?"\s+\(?\s*\.\s*\)?\s*}}/,
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
/**
|
|
@@ -55,6 +56,12 @@ const rewriteTag = function (token, src, endTags, liveMarkup) {
|
|
|
55
56
|
} else if (liveMarkup && tokens.BOOKSHOP.test(raw)) {
|
|
56
57
|
let [, name, params] = raw.match(tokens.BOOKSHOP);
|
|
57
58
|
outputToken.text = `{{ \`<!--bookshop-live name(${name}) params(.: ${params})-->\` | safeHTML }}${outputToken.text}{{ \`<!--bookshop-live end-->\` | safeHTML }}`
|
|
59
|
+
} else if (liveMarkup && tokens.BOOKSHOP_SCOPED.test(raw)) {
|
|
60
|
+
outputToken.text = [`{{ if reflect.IsSlice . }}{{ (printf \`<!--bookshop-live name(%s) params(.: .)-->\` (index . 0)) | safeHTML }}`,
|
|
61
|
+
`{{- else if reflect.IsMap . -}}{{ (printf \`<!--bookshop-live name(%s) params(.: .)-->\` ._bookshop_name) | safeHTML }}{{ end }}`,
|
|
62
|
+
`${outputToken.text}`,
|
|
63
|
+
`{{ \`<!--bookshop-live end-->\` | safeHTML }}`
|
|
64
|
+
].join('');
|
|
58
65
|
}
|
|
59
66
|
|
|
60
67
|
return outputToken;
|
|
@@ -11,6 +11,17 @@ test("add live markup to bookshop tags", t => {
|
|
|
11
11
|
t.is(translateTextTemplate(input, {}), expected);
|
|
12
12
|
});
|
|
13
13
|
|
|
14
|
+
test("add live markup to scoped bookshop tags", t => {
|
|
15
|
+
const input = `{{ partial "bookshop" . }}`;
|
|
16
|
+
const expected = [
|
|
17
|
+
`{{ if reflect.IsSlice . }}{{ (printf \`<!--bookshop-live name(%s) params(.: .)-->\` (index . 0)) | safeHTML }}`,
|
|
18
|
+
`{{- else if reflect.IsMap . -}}{{ (printf \`<!--bookshop-live name(%s) params(.: .)-->\` ._bookshop_name) | safeHTML }}{{ end }}`,
|
|
19
|
+
`{{ partial "bookshop" . }}`,
|
|
20
|
+
`{{ \`<!--bookshop-live end-->\` | safeHTML }}`
|
|
21
|
+
].join('');
|
|
22
|
+
t.is(translateTextTemplate(input, {}), expected);
|
|
23
|
+
});
|
|
24
|
+
|
|
14
25
|
test("add live markup to bookshop_partial tags", t => {
|
|
15
26
|
const input = `{{ partial "bookshop_partial" (slice "helper" (dict "text" "input")) }}`;
|
|
16
27
|
const expected = [
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bookshop/hugo-engine",
|
|
3
3
|
"packageManager": "yarn@3.0.0",
|
|
4
|
-
"version": "2.4.0-hugo.
|
|
4
|
+
"version": "2.4.0-hugo.4",
|
|
5
5
|
"description": "Bookshop frontend Hugo renderer",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"sideEffects": false,
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"nyc": "^15.1.0"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@bookshop/helpers": "2.4.0-hugo.
|
|
32
|
+
"@bookshop/helpers": "2.4.0-hugo.4",
|
|
33
33
|
"esbuild": "^0.13.10",
|
|
34
34
|
"liquidjs": "9.28.0"
|
|
35
35
|
},
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"parent":null,"pid":8768,"argv":["/Users/liambigelow/.nvm/versions/node/v14.16.0/bin/node","/Users/liambigelow/Projects/CC/bookshop/javascript-modules/node_modules/ava/cli.js","-v"],"execArgv":[],"cwd":"/Users/liambigelow/Projects/CC/bookshop/javascript-modules/engines/hugo-engine","time":1643516282634,"ppid":8749,"coverageFilename":"/Users/liambigelow/Projects/CC/bookshop/javascript-modules/engines/hugo-engine/.nyc_output/05cdaf09-20ac-4f20-a9c6-2b88c3a0faf2.json","externalId":"","uuid":"05cdaf09-20ac-4f20-a9c6-2b88c3a0faf2","files":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"parent":"05cdaf09-20ac-4f20-a9c6-2b88c3a0faf2","pid":8805,"argv":["/Users/liambigelow/.nvm/versions/node/v14.16.0/bin/node","/Users/liambigelow/Projects/CC/bookshop/javascript-modules/node_modules/ava/lib/worker/subprocess.js"],"execArgv":[],"cwd":"/Users/liambigelow/Projects/CC/bookshop/javascript-modules/engines/hugo-engine","time":1643516283165,"ppid":8768,"coverageFilename":"/Users/liambigelow/Projects/CC/bookshop/javascript-modules/engines/hugo-engine/.nyc_output/6e19d05c-cf57-446d-a6c8-7daaaf0e7db6.json","externalId":"","uuid":"6e19d05c-cf57-446d-a6c8-7daaaf0e7db6","files":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"parent":"05cdaf09-20ac-4f20-a9c6-2b88c3a0faf2","pid":8806,"argv":["/Users/liambigelow/.nvm/versions/node/v14.16.0/bin/node","/Users/liambigelow/Projects/CC/bookshop/javascript-modules/node_modules/ava/lib/worker/subprocess.js"],"execArgv":[],"cwd":"/Users/liambigelow/Projects/CC/bookshop/javascript-modules/engines/hugo-engine","time":1643516283171,"ppid":8768,"coverageFilename":"/Users/liambigelow/Projects/CC/bookshop/javascript-modules/engines/hugo-engine/.nyc_output/7f3f24c5-d070-4832-a421-c10f43bb42c3.json","externalId":"","uuid":"7f3f24c5-d070-4832-a421-c10f43bb42c3","files":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"parent":"05cdaf09-20ac-4f20-a9c6-2b88c3a0faf2","pid":8807,"argv":["/Users/liambigelow/.nvm/versions/node/v14.16.0/bin/node","/Users/liambigelow/Projects/CC/bookshop/javascript-modules/node_modules/ava/lib/worker/subprocess.js"],"execArgv":[],"cwd":"/Users/liambigelow/Projects/CC/bookshop/javascript-modules/engines/hugo-engine","time":1643516283175,"ppid":8768,"coverageFilename":"/Users/liambigelow/Projects/CC/bookshop/javascript-modules/engines/hugo-engine/.nyc_output/aa72646f-c2f6-4103-b57f-22eacd776b6f.json","externalId":"","uuid":"aa72646f-c2f6-4103-b57f-22eacd776b6f","files":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"parent":"05cdaf09-20ac-4f20-a9c6-2b88c3a0faf2","pid":8808,"argv":["/Users/liambigelow/.nvm/versions/node/v14.16.0/bin/node","/Users/liambigelow/Projects/CC/bookshop/javascript-modules/node_modules/ava/lib/worker/subprocess.js"],"execArgv":[],"cwd":"/Users/liambigelow/Projects/CC/bookshop/javascript-modules/engines/hugo-engine","time":1643516283179,"ppid":8768,"coverageFilename":"/Users/liambigelow/Projects/CC/bookshop/javascript-modules/engines/hugo-engine/.nyc_output/c924a9c2-577c-44b7-9c5c-b515d364fc95.json","externalId":"","uuid":"c924a9c2-577c-44b7-9c5c-b515d364fc95","files":[]}
|