@@ -13,19 +13,14 @@ module.exports = function (currentPattern, patternlab) {
13
13
14
14
const processRecursive = require ( './processRecursive' ) ;
15
15
16
- console . log ( '15 currentPattern' , currentPattern . patternPartial )
17
-
18
16
//find how many partials there may be for the given pattern
19
17
const foundPatternPartials = currentPattern . findPartials ( ) ;
20
18
21
- console . log ( 20 , currentPattern . patternPartial , foundPatternPartials )
22
-
23
19
// expand any partials present in this pattern; that is, drill down into
24
20
// the template and replace their calls in this template with rendered
25
21
// results
26
22
if ( currentPattern . engine . expandPartials && ( foundPatternPartials !== null && foundPatternPartials . length > 0 ) ) {
27
23
28
-
29
24
logger . debug ( `found partials for ${ currentPattern . patternPartial } ` ) ;
30
25
31
26
// determine if the template contains any pattern parameters. if so they
@@ -36,22 +31,13 @@ module.exports = function (currentPattern, patternlab) {
36
31
foundPatternPartials . forEach ( ( foundPartial ) => {
37
32
38
33
var partial = currentPattern . findPartial ( foundPartial ) ;
39
- var partialPath ;
40
-
41
- //identify which pattern this partial corresponds to
42
- for ( var j = 0 ; j < patternlab . patterns . length ; j ++ ) {
43
- if ( patternlab . patterns [ j ] . patternPartial === partial ||
44
- patternlab . patterns [ j ] . relPath . indexOf ( partial ) > - 1 )
45
- {
46
- partialPath = patternlab . patterns [ j ] . relPath ;
47
- }
48
- }
34
+ var partialPattern = getPartial ( partial , patternlab ) ;
49
35
50
36
//recurse through nested partials to fill out this extended template.
51
- return processRecursive ( partialPath , patternlab ) . then ( ( ) => { //eslint-disable-line no-loop-func
37
+ return processRecursive ( partialPattern . relPath , patternlab ) . then ( ( ) => { //eslint-disable-line no-loop-func
38
+
52
39
//complete assembly of extended template
53
40
//create a copy of the partial so as to not pollute it after the getPartial call.
54
- var partialPattern = getPartial ( partial , patternlab ) ;
55
41
var cleanPartialPattern = jsonCopy ( partialPattern , `partial pattern ${ partial } ` ) ;
56
42
57
43
//if partial has style modifier data, replace the styleModifier value
@@ -62,24 +48,17 @@ module.exports = function (currentPattern, patternlab) {
62
48
//this is what we came here for
63
49
logger . debug ( `within ${ currentPattern . patternPartial } , replacing extendedTemplate partial ${ foundPartial } with ${ cleanPartialPattern . patternPartial } 's extendedTemplate` ) ;
64
50
65
- //console.log(`decompose 58 within ${currentPattern.patternPartial}, replacing extendedTemplate partial ${foundPartial} with ${cleanPartialPattern.patternPartial}'s extededTemplate`)
66
- //console.log(currentPattern.extendedTemplate);
67
- //console.log(cleanPartialPattern.extendedTemplate);
68
51
currentPattern . extendedTemplate = currentPattern . extendedTemplate . replace ( foundPartial , cleanPartialPattern . extendedTemplate ) ;
69
52
70
53
// update the extendedTemplate in the partials object in case this
71
54
// pattern is consumed later
72
55
patternlab . partials [ currentPattern . patternPartial ] = currentPattern . extendedTemplate ;
73
56
74
- //console.log(62, `currentPattern ${currentPattern.patternPartial} .extendedTemplate now ${currentPattern.extendedTemplate}`)
75
57
return Promise . resolve ( ) ;
76
58
} ) . catch ( reason => {
77
59
console . log ( reason )
78
60
logger . error ( reason ) ;
79
61
} ) ;
80
-
81
- console . log ( '82 is bad' )
82
-
83
62
} ) ;
84
63
85
64
} ) . catch ( reason => {
0 commit comments