@@ -14,16 +14,22 @@ const prefixMatcher = /^_?(\d+-)?/;
14
14
*
15
15
* Before changing functionalities of the pattern object please read the following pull requests
16
16
* to get more details about the behavior of the folder structure
17
+ * https://patternlab.io/docs/overview-of-patterns/#heading-deeper-nesting
17
18
* https://github.com/pattern-lab/patternlab-node/pull/992
18
19
* https://github.com/pattern-lab/patternlab-node/pull/1016
19
20
* https://github.com/pattern-lab/patternlab-node/pull/1143
20
21
*
21
- * @param {String } relPath relative directory
22
+ * @param {string } relPath relative directory
22
23
* @param {Object } jsonFileData The JSON used to render values in the pattern.
23
- * @param {Patternlab } patternlab The actual patternlab instance
24
- * @param {Boolean } isUnsubRun specifies if the pattern needs to be removed from its subfolder
24
+ * @param {Patternlab } patternlab The actual pattern lab instance
25
+ * @param {boolean } isPromoteToFlatPatternRun specifies if the pattern needs to be removed from its deep nesting folder
25
26
*/
26
- const Pattern = function ( relPath , jsonFileData , patternlab , isUnsubRun ) {
27
+ const Pattern = function (
28
+ relPath ,
29
+ jsonFileData ,
30
+ patternlab ,
31
+ isPromoteToFlatPatternRun
32
+ ) {
27
33
this . relPath = path . normalize ( relPath ) ; // '00-atoms/00-global/00-colors.mustache'
28
34
29
35
/**
@@ -32,13 +38,17 @@ const Pattern = function(relPath, jsonFileData, patternlab, isUnsubRun) {
32
38
*/
33
39
const pathObj = path . parse ( this . relPath ) ;
34
40
35
- const info = this . getPatternInfo ( pathObj , patternlab , isUnsubRun ) ;
41
+ const info = this . getPatternInfo (
42
+ pathObj ,
43
+ patternlab ,
44
+ isPromoteToFlatPatternRun
45
+ ) ;
36
46
37
47
this . fileName = pathObj . name ; // '00-colors'
38
48
this . subdir = pathObj . dir ; // '00-atoms/00-global'
39
49
this . fileExtension = pathObj . ext ; // '.mustache'
40
50
41
- // TODO: Remove if when droping ordering by prefix and keep else code
51
+ // TODO: Remove if when dropping ordering by prefix and keep else code
42
52
if ( info . patternHasOwnDir ) {
43
53
// Since there is still the requirement of having the numbers provided for sorting
44
54
// this will be required to keep the folder prefix and the variant name
@@ -80,7 +90,7 @@ const Pattern = function(relPath, jsonFileData, patternlab, isUnsubRun) {
80
90
// the joined pattern group and subgroup directory
81
91
this . flatPatternPath = info . shortNotation ; // '00-atoms-00-global'
82
92
83
- // calculated path from the root of the public directory to the generated
93
+ // Calculated path from the root of the public directory to the generated
84
94
// (rendered!) html file for this pattern, to be shown in the iframe
85
95
this . patternLink = patternlab
86
96
? this . getPatternLink ( patternlab , 'rendered' )
@@ -128,7 +138,7 @@ const Pattern = function(relPath, jsonFileData, patternlab, isUnsubRun) {
128
138
this . compileState = null ;
129
139
130
140
/**
131
- * Timestamp in milliseconds when the pattern template or auxilary file (e.g. json) were modified.
141
+ * Timestamp in milliseconds when the pattern template or auxiliary file (e.g. json) were modified.
132
142
* If multiple files are affected, this is the timestamp of the most recent change.
133
143
*
134
144
* @see {@link pattern }
@@ -175,8 +185,8 @@ Pattern.prototype = {
175
185
* Should look something like '00-atoms-00-global-00-colors/00-atoms-00-global-00-colors.html'
176
186
*
177
187
* @param {Patternlab } patternlab Current patternlab instance
178
- * @param {String } suffixType File suffix
179
- * @param {String } customfileExtension Custom extension
188
+ * @param {string } suffixType File suffix
189
+ * @param {string } customfileExtension Custom extension
180
190
*/
181
191
getPatternLink : function ( patternlab , suffixType , customfileExtension ) {
182
192
// if no suffixType is provided, we default to rendered
@@ -216,8 +226,8 @@ Pattern.prototype = {
216
226
return this . engine . findListItems ( this ) ;
217
227
} ,
218
228
219
- findPartial : function ( partialString ) {
220
- return this . engine . findPartial ( partialString ) ;
229
+ findPartial : function ( partialstring ) {
230
+ return this . engine . findPartial ( partialstring ) ;
221
231
} ,
222
232
223
233
/**
@@ -235,7 +245,7 @@ Pattern.prototype = {
235
245
} else if ( level >= 1 ) {
236
246
return '' ;
237
247
} else {
238
- // Im Not quite shure about that but its better than empty node
248
+ // I'm not quite sure about that but its better than empty node
239
249
// TODO: verify
240
250
return 'root' ;
241
251
}
@@ -248,7 +258,7 @@ Pattern.prototype = {
248
258
*
249
259
* @param {Patternlab } patternlab Current patternlab instance
250
260
*/
251
- resetSubbing : function ( patternlab ) {
261
+ promoteFromDirectoryToFlatPattern : function ( patternlab ) {
252
262
const p = new Pattern ( this . relPath , this . jsonFileData , patternlab , true ) ;
253
263
// Only reset the specific fields, not everything
254
264
Object . assign ( this , {
@@ -266,17 +276,18 @@ Pattern.prototype = {
266
276
} ,
267
277
268
278
/**
269
- * Info contains information about pattern structure if it is a nested pattern
270
- * or if it just a subfolder structure. Its just used for internal purposes.
271
- * Remember every pattern infomarion based on "this.*" will be used by other functions
279
+ * The "info" object contains information about pattern structure if it is
280
+ * a nested pattern or if it just a sub folder structure. It's just used for
281
+ * internal purposes. Remember every pattern information based on "this.*"
282
+ * will be used by other functions
272
283
*
273
- * @param pathObj path.parse() object containing usefull path information
284
+ * @param pathObj path.parse() object containing useful path information
274
285
*/
275
- getPatternInfo : ( pathObj , patternlab , isUnsubRun ) => {
286
+ getPatternInfo : ( pathObj , patternlab , isPromoteToFlatPatternRun ) => {
276
287
const info = {
277
- // 00-colors(.mustache) is subfolder in 00-atoms-/00-global/00-colors
288
+ // 00-colors(.mustache) is deeply nested in 00-atoms-/00-global/00-colors
278
289
patternlab : patternlab ,
279
- patternHasOwnDir : ! isUnsubRun
290
+ patternHasOwnDir : ! isPromoteToFlatPatternRun
280
291
? path . basename ( pathObj . dir ) . replace ( prefixMatcher , '' ) ===
281
292
pathObj . name . replace ( prefixMatcher , '' ) ||
282
293
path . basename ( pathObj . dir ) . replace ( prefixMatcher , '' ) ===
@@ -333,7 +344,7 @@ Pattern.createEmpty = function(customProps, patternlab) {
333
344
} ;
334
345
335
346
/**
336
- * factory: creates an Pattern object on-demand from a hash; the hash accepts
347
+ * factory: creates a Pattern object on-demand from a hash; the hash accepts
337
348
* parameters that replace the positional parameters that the Pattern
338
349
* constructor takes.
339
350
*/
0 commit comments