@@ -14,16 +14,22 @@ const prefixMatcher = /^_?(\d+-)?/;
1414 *
1515 * Before changing functionalities of the pattern object please read the following pull requests
1616 * to get more details about the behavior of the folder structure
17+ * https://patternlab.io/docs/overview-of-patterns/#heading-deeper-nesting
1718 * https://github.com/pattern-lab/patternlab-node/pull/992
1819 * https://github.com/pattern-lab/patternlab-node/pull/1016
1920 * https://github.com/pattern-lab/patternlab-node/pull/1143
2021 *
21- * @param {String } relPath relative directory
22+ * @param {string } relPath relative directory
2223 * @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
2526 */
26- const Pattern = function ( relPath , jsonFileData , patternlab , isUnsubRun ) {
27+ const Pattern = function (
28+ relPath ,
29+ jsonFileData ,
30+ patternlab ,
31+ isPromoteToFlatPatternRun
32+ ) {
2733 this . relPath = path . normalize ( relPath ) ; // '00-atoms/00-global/00-colors.mustache'
2834
2935 /**
@@ -32,13 +38,17 @@ const Pattern = function(relPath, jsonFileData, patternlab, isUnsubRun) {
3238 */
3339 const pathObj = path . parse ( this . relPath ) ;
3440
35- const info = this . getPatternInfo ( pathObj , patternlab , isUnsubRun ) ;
41+ const info = this . getPatternInfo (
42+ pathObj ,
43+ patternlab ,
44+ isPromoteToFlatPatternRun
45+ ) ;
3646
3747 this . fileName = pathObj . name ; // '00-colors'
3848 this . subdir = pathObj . dir ; // '00-atoms/00-global'
3949 this . fileExtension = pathObj . ext ; // '.mustache'
4050
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
4252 if ( info . patternHasOwnDir ) {
4353 // Since there is still the requirement of having the numbers provided for sorting
4454 // this will be required to keep the folder prefix and the variant name
@@ -80,7 +90,7 @@ const Pattern = function(relPath, jsonFileData, patternlab, isUnsubRun) {
8090 // the joined pattern group and subgroup directory
8191 this . flatPatternPath = info . shortNotation ; // '00-atoms-00-global'
8292
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
8494 // (rendered!) html file for this pattern, to be shown in the iframe
8595 this . patternLink = patternlab
8696 ? this . getPatternLink ( patternlab , 'rendered' )
@@ -128,7 +138,7 @@ const Pattern = function(relPath, jsonFileData, patternlab, isUnsubRun) {
128138 this . compileState = null ;
129139
130140 /**
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.
132142 * If multiple files are affected, this is the timestamp of the most recent change.
133143 *
134144 * @see {@link pattern }
@@ -175,8 +185,8 @@ Pattern.prototype = {
175185 * Should look something like '00-atoms-00-global-00-colors/00-atoms-00-global-00-colors.html'
176186 *
177187 * @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
180190 */
181191 getPatternLink : function ( patternlab , suffixType , customfileExtension ) {
182192 // if no suffixType is provided, we default to rendered
@@ -216,8 +226,8 @@ Pattern.prototype = {
216226 return this . engine . findListItems ( this ) ;
217227 } ,
218228
219- findPartial : function ( partialString ) {
220- return this . engine . findPartial ( partialString ) ;
229+ findPartial : function ( partialstring ) {
230+ return this . engine . findPartial ( partialstring ) ;
221231 } ,
222232
223233 /**
@@ -235,7 +245,7 @@ Pattern.prototype = {
235245 } else if ( level >= 1 ) {
236246 return '' ;
237247 } 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
239249 // TODO: verify
240250 return 'root' ;
241251 }
@@ -248,7 +258,7 @@ Pattern.prototype = {
248258 *
249259 * @param {Patternlab } patternlab Current patternlab instance
250260 */
251- resetSubbing : function ( patternlab ) {
261+ promoteFromDirectoryToFlatPattern : function ( patternlab ) {
252262 const p = new Pattern ( this . relPath , this . jsonFileData , patternlab , true ) ;
253263 // Only reset the specific fields, not everything
254264 Object . assign ( this , {
@@ -266,17 +276,18 @@ Pattern.prototype = {
266276 } ,
267277
268278 /**
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
272283 *
273- * @param pathObj path.parse() object containing usefull path information
284+ * @param pathObj path.parse() object containing useful path information
274285 */
275- getPatternInfo : ( pathObj , patternlab , isUnsubRun ) => {
286+ getPatternInfo : ( pathObj , patternlab , isPromoteToFlatPatternRun ) => {
276287 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
278289 patternlab : patternlab ,
279- patternHasOwnDir : ! isUnsubRun
290+ patternHasOwnDir : ! isPromoteToFlatPatternRun
280291 ? path . basename ( pathObj . dir ) . replace ( prefixMatcher , '' ) ===
281292 pathObj . name . replace ( prefixMatcher , '' ) ||
282293 path . basename ( pathObj . dir ) . replace ( prefixMatcher , '' ) ===
@@ -333,7 +344,7 @@ Pattern.createEmpty = function(customProps, patternlab) {
333344} ;
334345
335346/**
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
337348 * parameters that replace the positional parameters that the Pattern
338349 * constructor takes.
339350 */
0 commit comments