24
24
25
25
var Handlebars = require ( 'handlebars' ) ;
26
26
27
+ // regexes, stored here so they're only compiled once
28
+ const findPartialsRE = / { { # ? > \s * ( [ \w -\/ . ] + ) (?: .| \s + ) * ?} } / g;
29
+ const findListItemsRE = / ( { { # ( ) ? ) ( l i s t ( I | i ) t e m s .) ( o n e | t w o | t h r e e | f o u r | f i v e | s i x | s e v e n | e i g h t | n i n e | t e n | e l e v e n | t w e l v e | t h i r t e e n | f o u r t e e n | f i f t e e n | s i x t e e n | s e v e n t e e n | e i g h t e e n | n i n e t e e n | t w e n t y ) ( ) ? } } / g;
30
+
27
31
var engine_handlebars = {
28
32
engine : Handlebars ,
29
33
engineName : 'handlebars' ,
@@ -33,10 +37,6 @@ var engine_handlebars = {
33
37
// style modifiers or pattern parameters (I think)
34
38
expandPartials : false ,
35
39
36
- // regexes, stored here so they're only compiled once
37
- findPartialsRE : / { { # ? > \s * ( [ \w -\/ . ] + ) (?: .| \s + ) * ?} } / g,
38
- findListItemsRE : / ( { { # ( ) ? ) ( l i s t ( I | i ) t e m s .) ( o n e | t w o | t h r e e | f o u r | f i v e | s i x | s e v e n | e i g h t | n i n e | t e n | e l e v e n | t w e l v e | t h i r t e e n | f o u r t e e n | f i f t e e n | s i x t e e n | s e v e n t e e n | e i g h t e e n | n i n e t e e n | t w e n t y ) ( ) ? } } / g,
39
-
40
40
// render it
41
41
renderPattern : function renderPattern ( pattern , data , partials ) {
42
42
if ( partials ) {
@@ -56,7 +56,7 @@ var engine_handlebars = {
56
56
57
57
// find and return any {{> template-name }} within pattern
58
58
findPartials : function findPartials ( pattern ) {
59
- var matches = pattern . template . match ( this . findPartialsRE ) ;
59
+ var matches = pattern . template . match ( findPartialsRE ) ;
60
60
return matches ;
61
61
} ,
62
62
findPartialsWithStyleModifiers : function ( ) {
@@ -73,14 +73,14 @@ var engine_handlebars = {
73
73
return [ ] ;
74
74
} ,
75
75
findListItems : function ( pattern ) {
76
- var matches = pattern . template . match ( this . findListItemsRE ) ;
76
+ var matches = pattern . template . match ( findListItemsRE ) ;
77
77
return matches ;
78
78
} ,
79
79
80
80
// given a pattern, and a partial string, tease out the "pattern key" and
81
81
// return it.
82
82
findPartial : function ( partialString ) {
83
- var partial = partialString . replace ( this . findPartialsRE , '$1' ) ;
83
+ var partial = partialString . replace ( findPartialsRE , '$1' ) ;
84
84
return partial ;
85
85
}
86
86
} ;
0 commit comments