Skip to content

Commit 4ff84d0

Browse files
refactor: remove parameter hunter (#1467)
* refactor: remove parameter hunter * refactor: remove parameter hunter * fix: issue in mustache runable * docs: adapted documentation --------- Co-authored-by: Josef Bredreck <[email protected]> Co-authored-by: Josef Bredreck <[email protected]>
1 parent a4d9332 commit 4ff84d0

File tree

4 files changed

+35
-941
lines changed

4 files changed

+35
-941
lines changed
+34-46
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
'use strict';
22

33
const logger = require('./log');
4-
const ph = require('./parameter_hunter');
54
const jsonCopy = require('./json_copy');
65
const getPartial = require('./get');
76

8-
const parameter_hunter = new ph();
9-
7+
// TODO: remove when removing mustache
108
module.exports = function (currentPattern, patternlab) {
119
const processRecursive = require('./processRecursive');
1210

@@ -23,56 +21,46 @@ module.exports = function (currentPattern, patternlab) {
2321
) {
2422
logger.debug(`found partials for ${currentPattern.patternPartial}`);
2523

26-
// determine if the template contains any pattern parameters. if so they
27-
// must be immediately consumed
28-
return parameter_hunter
29-
.find_parameters(currentPattern, patternlab)
30-
.then(() => {
31-
//do something with the regular old partials
32-
foundPatternPartials.forEach((foundPartial) => {
33-
const partial = currentPattern.findPartial(foundPartial);
34-
const partialPattern = getPartial(partial, patternlab);
24+
//do something with the regular old partials
25+
foundPatternPartials.forEach((foundPartial) => {
26+
const partial = currentPattern.findPartial(foundPartial);
27+
const partialPattern = getPartial(partial, patternlab);
3528

36-
//recurse through nested partials to fill out this extended template.
37-
return processRecursive(partialPattern.relPath, patternlab)
38-
.then(() => {
39-
//eslint-disable-line no-loop-func
29+
//recurse through nested partials to fill out this extended template.
30+
return processRecursive(partialPattern.relPath, patternlab)
31+
.then(() => {
32+
//eslint-disable-line no-loop-func
4033

41-
//complete assembly of extended template
42-
//create a copy of the partial so as to not pollute it after the getPartial call.
43-
const cleanPartialPattern = jsonCopy(
44-
partialPattern,
45-
`partial pattern ${partial}`
46-
);
34+
//complete assembly of extended template
35+
//create a copy of the partial so as to not pollute it after the getPartial call.
36+
const cleanPartialPattern = jsonCopy(
37+
partialPattern,
38+
`partial pattern ${partial}`
39+
);
4740

48-
//this is what we came here for
49-
logger.debug(
50-
`within ${currentPattern.patternPartial}, replacing extendedTemplate partial ${foundPartial} with ${cleanPartialPattern.patternPartial}'s extendedTemplate`
51-
);
41+
//this is what we came here for
42+
logger.debug(
43+
`within ${currentPattern.patternPartial}, replacing extendedTemplate partial ${foundPartial} with ${cleanPartialPattern.patternPartial}'s extendedTemplate`
44+
);
5245

53-
currentPattern.extendedTemplate =
54-
currentPattern.extendedTemplate.replace(
55-
foundPartial,
56-
cleanPartialPattern.extendedTemplate
57-
);
46+
currentPattern.extendedTemplate =
47+
currentPattern.extendedTemplate.replace(
48+
foundPartial,
49+
cleanPartialPattern.extendedTemplate
50+
);
5851

59-
// update the extendedTemplate in the partials object in case this
60-
// pattern is consumed later
61-
patternlab.partials[currentPattern.patternPartial] =
62-
currentPattern.extendedTemplate;
52+
// update the extendedTemplate in the partials object in case this
53+
// pattern is consumed later
54+
patternlab.partials[currentPattern.patternPartial] =
55+
currentPattern.extendedTemplate;
6356

64-
return Promise.resolve();
65-
})
66-
.catch((reason) => {
67-
console.log(reason);
68-
logger.error(reason);
69-
});
57+
return Promise.resolve();
58+
})
59+
.catch((reason) => {
60+
console.log(reason);
61+
logger.error(reason);
7062
});
71-
})
72-
.catch((reason) => {
73-
console.log(reason);
74-
logger.error(reason);
75-
});
63+
});
7664
}
7765
return Promise.resolve();
7866
};

0 commit comments

Comments
 (0)