1
- /*
2
- * patternlab-node - v1.1.3 - 2016
3
- *
1
+ /*
2
+ * patternlab-node - v1.1.3 - 2016
3
+ *
4
4
* Brian Muenzenmeyer, and the web community.
5
- * Licensed under the MIT license.
6
- *
7
- * Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice.
5
+ * Licensed under the MIT license.
6
+ *
7
+ * Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice.
8
8
*
9
9
*/
10
10
13
13
14
14
var pattern_assembler = function ( ) {
15
15
16
- function isObjectEmpty ( obj ) {
17
- for ( var prop in obj ) {
18
- if ( obj . hasOwnProperty ( prop ) ) { return false ; }
19
- }
20
- return true ;
21
- }
22
-
23
16
// returns any patterns that match {{> value:mod }} or {{> value:mod(foo:"bar") }} within the pattern
24
17
function findPartialsWithStyleModifiers ( pattern ) {
25
18
var matches = pattern . template . match ( / { { > ( [ ] ) ? ( [ \w \- \. \/ ~ ] + ) (? ! \( ) ( \: [ A - Z a - z 0 - 9 - _ | ] + ) + (?: ( | ) \( .* ) ? ( [ ] ) ? } } / g) ;
@@ -67,7 +60,7 @@ var pattern_assembler = function () {
67
60
break ;
68
61
}
69
62
}
70
-
63
+
71
64
//if the pattern is new, just push to the array
72
65
if ( isNew ) {
73
66
patternlab . patterns . push ( pattern ) ;
@@ -249,7 +242,7 @@ var pattern_assembler = function () {
249
242
250
243
function getpatternbykey ( key , patternlab ) {
251
244
var i ; // for the for loops
252
-
245
+
253
246
//look for exact key matches
254
247
for ( i = 0 ; i < patternlab . patterns . length ; i ++ ) {
255
248
if ( patternlab . patterns [ i ] . key === key ) {
@@ -271,7 +264,7 @@ var pattern_assembler = function () {
271
264
var keyParts = key . split ( '-' ) ,
272
265
keyType = keyParts [ 0 ] ,
273
266
keyName = keyParts . slice ( 1 ) . join ( '-' ) ;
274
-
267
+
275
268
if ( patternlab . patterns [ i ] . key . split ( '-' ) [ 0 ] === keyType && patternlab . patterns [ i ] . key . indexOf ( keyName ) > - 1 ) {
276
269
return patternlab . patterns [ i ] ;
277
270
}
@@ -293,7 +286,7 @@ var pattern_assembler = function () {
293
286
obj2 [ p ] = { } ;
294
287
}
295
288
obj2 [ p ] = mergeData ( obj1 [ p ] , obj2 [ p ] ) ;
296
-
289
+
297
290
// Pop when recursion meets a non-object. If obj1[p] is a non-object,
298
291
// only copy to undefined obj2[p]. This way, obj2 maintains priority.
299
292
} else if ( typeof obj2 [ p ] === 'undefined' ) {
@@ -360,7 +353,7 @@ var pattern_assembler = function () {
360
353
}
361
354
return JSON . parse ( dataObjAsString ) ;
362
355
}
363
-
356
+
364
357
//look for pattern links included in data files.
365
358
//these will be in the form of link.* WITHOUT {{}}, which would still be there from direct pattern inclusion
366
359
function parseDataLinks ( patternlab ) {
@@ -411,9 +404,6 @@ var pattern_assembler = function () {
411
404
combine_listItems : function ( patternlab ) {
412
405
buildListItems ( patternlab ) ;
413
406
} ,
414
- is_object_empty : function ( obj ) {
415
- return isObjectEmpty ( obj ) ;
416
- } ,
417
407
parse_data_links : function ( patternlab ) {
418
408
parseDataLinks ( patternlab ) ;
419
409
}
0 commit comments