This repository was archived by the owner on Dec 10, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +74
-0
lines changed Expand file tree Collapse file tree 2 files changed +74
-0
lines changed Original file line number Diff line number Diff line change
1
+ /*
2
+ * mustache pattern engine for patternlab-node - v0.10.1 - 2015
3
+ *
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.
8
+ *
9
+ */
10
+
11
+ ( function ( ) {
12
+ "use strict" ;
13
+
14
+ var Mustache = require ( 'mustache' ) ;
15
+
16
+ var engine_mustache = {
17
+ engine : Mustache ,
18
+ fileExtension : '.mustache' ,
19
+
20
+ // render it
21
+ renderPattern : function renderPattern ( template , data , partials ) {
22
+ if ( partials ) {
23
+ return Mustache . render ( template , data , partials ) ;
24
+ }
25
+ return Mustache . render ( template , data ) ;
26
+ } ,
27
+
28
+ // find and return any {{> template-name }} within pattern
29
+ findPartials : function findPartials ( pattern ) {
30
+ var matches = pattern . template . match ( / { { > ( [ ] ) ? ( [ A - Z a - z 0 - 9 - ] + ) (?: \: [ A - Z a - z 0 - 9 - ] + ) ? (?: ( | ) \( .* ) ? ( [ ] ) ? } } / g) ;
31
+ return matches ;
32
+ }
33
+ } ;
34
+
35
+ module . exports = engine_mustache ;
36
+ } ) ( ) ;
Original file line number Diff line number Diff line change
1
+ /*
2
+ * patternlab-node - v0.10.1 - 2015
3
+ *
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.
8
+ *
9
+ */
10
+
11
+ ( function ( ) {
12
+ 'use strict' ;
13
+
14
+ // list of supported pattern engines
15
+ var supportedPatternEngineNames = [
16
+ 'mustache' ,
17
+ 'handlebars'
18
+ ] ;
19
+
20
+ // hash of all loaded pattern engines, empty at first
21
+ var patternEngines = { } ;
22
+
23
+ // try to load all supported engines
24
+ supportedPatternEngineNames . forEach ( function ( engineName ) {
25
+ try {
26
+ patternEngines [ engineName ] = require ( './engine_' + engineName ) ;
27
+ } catch ( err ) {
28
+ console . log ( err , 'pattern engine "' + engineName + '" not loaded. Did you install its dependency with npm?' ) ;
29
+ }
30
+ } ) ;
31
+
32
+ patternEngines . getEngineForPattern = function ( pattern ) {
33
+
34
+ } ;
35
+
36
+ module . exports = patternEngines ;
37
+
38
+ } ) ( ) ;
You can’t perform that action at this time.
0 commit comments