This repository was archived by the owner on Dec 10, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +16
-12
lines changed Expand file tree Collapse file tree 3 files changed +16
-12
lines changed Original file line number Diff line number Diff line change 68
68
}
69
69
}
70
70
71
- // template: a string containing the template text, not an oPattern
72
- function renderPattern ( template , data , partials ) {
73
- // TODO:
74
- // choose an appropriate pattern engine
75
- // call and return result of its renderPattern method
76
- // OR MAYBE: this should just be a method of oPattern
77
-
78
- var mustache = require ( 'mustache' ) ;
79
- if ( partials ) {
80
- return mustache . render ( template , data , partials ) ;
71
+ function renderPattern ( pattern , data , partials ) {
72
+ // if we've been passed a full oPattern, it knows what kind of template it
73
+ // is, and how to render itself, so we just call its render method
74
+ if ( pattern instanceof of . oPattern ) {
75
+ console . log ( 'rendering full oPattern' ) ;
76
+ return pattern . render ( pattern , data , partials ) ;
81
77
} else {
82
- return mustache . render ( template , data ) ;
78
+ // otherwise, assume it's a plain mustache template string and act
79
+ // accordingly
80
+ console . log ( 'rendering plain mustache string' ) ;
81
+ return patternEngines . mustache . renderPattern ( pattern , data , partials ) ;
83
82
}
84
83
}
85
84
Original file line number Diff line number Diff line change 15
15
16
16
var engine_mustache = {
17
17
engine : Mustache ,
18
+ name : 'mustache' ,
18
19
fileExtension : '.mustache' ,
19
20
20
21
// render it
Original file line number Diff line number Diff line change 25
25
// var Mustache = PatternEngines['mustache'];
26
26
//
27
27
var PatternEngines = Object . create ( {
28
- getEngineForPattern : function ( pattern ) {
28
+ getEngineNameForPattern : function ( pattern ) {
29
29
console . log ( 'pattern file name: ' , pattern . fileName ) ;
30
30
return 'mustache' ;
31
+ } ,
32
+ getEngineForPattern : function ( pattern ) {
33
+ var engineName = this . getEngineNameForPattern ( pattern ) ;
34
+ return this [ engineName ] ;
31
35
}
32
36
} ) ;
33
37
You can’t perform that action at this time.
0 commit comments