1
1
'use strict' ;
2
2
3
3
const logger = require ( './log' ) ;
4
- const ph = require ( './parameter_hunter' ) ;
5
4
const jsonCopy = require ( './json_copy' ) ;
6
5
const getPartial = require ( './get' ) ;
7
6
8
- const parameter_hunter = new ph ( ) ;
9
-
7
+ // TODO: remove when removing mustache
10
8
module . exports = function ( currentPattern , patternlab ) {
11
9
const processRecursive = require ( './processRecursive' ) ;
12
10
@@ -23,56 +21,46 @@ module.exports = function (currentPattern, patternlab) {
23
21
) {
24
22
logger . debug ( `found partials for ${ currentPattern . patternPartial } ` ) ;
25
23
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 ) ;
35
28
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
40
33
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
+ ) ;
47
40
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
+ ) ;
52
45
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
+ ) ;
58
51
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 ;
63
56
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 ) ;
70
62
} ) ;
71
- } )
72
- . catch ( ( reason ) => {
73
- console . log ( reason ) ;
74
- logger . error ( reason ) ;
75
- } ) ;
63
+ } ) ;
76
64
}
77
65
return Promise . resolve ( ) ;
78
66
} ;
0 commit comments