This repository was archived by the owner on Dec 10, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +42
-32
lines changed Expand file tree Collapse file tree 4 files changed +42
-32
lines changed Original file line number Diff line number Diff line change 1
- /*
2
- * patternlab-node - v0.10.1 - 2015
3
- *
1
+ /*
2
+ * patternlab-node - v0.10.1 - 2015
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
11
11
( function ( ) {
12
12
"use strict" ;
13
13
14
+ var PatternEngines = require ( 'pattern_engines/pattern_engines' ) ;
15
+
14
16
var oPattern = function ( subdir , filename , data ) {
15
17
this . fileName = filename . substring ( 0 , filename . indexOf ( '.' ) ) ;
16
18
this . subdir = subdir ;
29
31
this . lineageIndex = [ ] ;
30
32
this . lineageR = [ ] ;
31
33
this . lineageRIndex = [ ] ;
34
+ this . engine = PatternEngines . getEngineForPattern ( this ) ;
35
+ } ;
36
+ // render method on oPatterns; this acts as a proxy for the
37
+ oPattern . prototype . render = function ( data , partials ) {
38
+ return this . engine . render ( this . template , data , partials ) ;
32
39
} ;
33
40
34
41
var oBucket = function ( name ) {
Original file line number Diff line number Diff line change 1
- /*
2
- * patternlab-node - v0.10.1 - 2015
3
- *
1
+ /*
2
+ * patternlab-node - v0.10.1 - 2015
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
14
14
var parameter_hunter = function ( ) {
15
15
16
16
var extend = require ( 'util' ) . _extend ,
17
- pa = require ( './pattern_assembler ' ) ,
18
- mustache = require ( 'mustache' ) ,
19
- pattern_assembler = new pa ( ) ;
17
+ pa = require ( './pattern_asbsembler ' ) ,
18
+ mustache = require ( 'mustache' ) ,
19
+ pattern_assembler = new pa ( ) ;
20
20
21
21
function findparameters ( pattern , patternlab ) {
22
22
47
47
for ( var prop in paramData ) {
48
48
if ( existingData . hasOwnProperty ( prop ) ) {
49
49
existingData [ prop ] = paramData [ prop ] ;
50
- }
50
+ }
51
51
}
52
52
53
53
//extend pattern data links into link for pattern link shortcuts to work. we do this locally and globally
Original file line number Diff line number Diff line change 1
- /*
2
- * mustache pattern engine for patternlab-node - v0.10.1 - 2015
3
- *
1
+ /*
2
+ * mustache pattern engine for patternlab-node - v0.10.1 - 2015
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
31
31
return matches ;
32
32
}
33
33
} ;
34
-
34
+
35
35
module . exports = engine_mustache ;
36
36
} ) ( ) ;
Original file line number Diff line number Diff line change 17
17
'handlebars'
18
18
] ;
19
19
20
- // hash of all loaded pattern engines, empty at first
21
- var patternEngines = { } ;
20
+ // object/hash of all loaded pattern engines, empty at first
21
+ function PatternEngines ( ) {
22
+ // do nothing
23
+ }
24
+ PatternEngines . prototype = {
25
+ getEngineForPattern : function ( pattern ) {
26
+ console . log ( 'pattern file name: ' , pattern . fileName ) ;
27
+ return 'mustache' ;
28
+ }
29
+ } ;
22
30
23
31
// try to load all supported engines
24
32
supportedPatternEngineNames . forEach ( function ( engineName ) {
25
33
try {
26
- patternEngines [ engineName ] = require ( './engine_' + engineName ) ;
34
+ PatternEngines [ engineName ] = require ( './engine_' + engineName ) ;
27
35
} catch ( err ) {
28
36
console . log ( err , 'pattern engine "' + engineName + '" not loaded. Did you install its dependency with npm?' ) ;
29
37
}
30
38
} ) ;
31
39
32
- patternEngines . getEngineForPattern = function ( pattern ) {
33
-
34
- } ;
35
-
36
- module . exports = patternEngines ;
37
-
40
+ module . exports = new PatternEngines ( ) ;
38
41
} ) ( ) ;
You can’t perform that action at this time.
0 commit comments