@bigcommerce/stencil-cli 5.3.3 → 5.3.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/lib/template-assembler.js +14 -1
- package/package.json +1 -1
|
@@ -5,6 +5,7 @@ const path = require('path');
|
|
|
5
5
|
const upath = require('upath');
|
|
6
6
|
|
|
7
7
|
const partialRegex = /\{\{>\s*([_|\-|a-zA-Z0-9@'"/]+)[^{]*?}}/g;
|
|
8
|
+
const partialWithoutBracketsRegex = /[^>{{}}\s*]+/g;
|
|
8
9
|
const dynamicComponentRegex = /\{\{\s*?dynamicComponent\s*(?:'|")([_|\-|a-zA-Z0-9/]+)(?:'|").*?}}/g;
|
|
9
10
|
const includeRegex = /{{2}>\s*([_|\-|a-zA-Z0-9/]+)[^{]*?}{2}/g;
|
|
10
11
|
const pathStringRegex = /^["'].+["']$/;
|
|
@@ -23,12 +24,24 @@ const defineBaseRoute = (route) => route.split('/').slice(0, 3).join('/');
|
|
|
23
24
|
const applyExternalPath = (templateName, templates) => {
|
|
24
25
|
return templates.map((t) => `${defineBaseRoute(templateName)}/${t}`);
|
|
25
26
|
};
|
|
27
|
+
const modifyNestedPartial = (partial) => {
|
|
28
|
+
const partialFragments = partial.match(partialWithoutBracketsRegex);
|
|
29
|
+
|
|
30
|
+
if (partialFragments) {
|
|
31
|
+
return [`${partialFragments.shift()}'`, ...partialFragments].join(' ');
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return partialFragments;
|
|
35
|
+
};
|
|
36
|
+
|
|
26
37
|
const replacePartialNames = (content, partialRoute) => {
|
|
27
38
|
return content.replace(
|
|
28
39
|
includeRegex,
|
|
29
|
-
(
|
|
40
|
+
(partialName) =>
|
|
41
|
+
`{{> '${defineBaseRoute(partialRoute)}/${modifyNestedPartial(partialName)} }}`,
|
|
30
42
|
);
|
|
31
43
|
};
|
|
44
|
+
|
|
32
45
|
const trimPartial = (partial) => {
|
|
33
46
|
if (pathStringRegex.test(partial)) {
|
|
34
47
|
return partial.slice(1, -1);
|