2424
2525var Handlebars = require ( 'handlebars' ) ;
2626
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+
2731var engine_handlebars = {
2832 engine : Handlebars ,
2933 engineName : 'handlebars' ,
@@ -33,10 +37,6 @@ var engine_handlebars = {
3337 // style modifiers or pattern parameters (I think)
3438 expandPartials : false ,
3539
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-
4040 // render it
4141 renderPattern : function renderPattern ( pattern , data , partials ) {
4242 if ( partials ) {
@@ -56,7 +56,7 @@ var engine_handlebars = {
5656
5757 // find and return any {{> template-name }} within pattern
5858 findPartials : function findPartials ( pattern ) {
59- var matches = pattern . template . match ( this . findPartialsRE ) ;
59+ var matches = pattern . template . match ( findPartialsRE ) ;
6060 return matches ;
6161 } ,
6262 findPartialsWithStyleModifiers : function ( ) {
@@ -73,14 +73,14 @@ var engine_handlebars = {
7373 return [ ] ;
7474 } ,
7575 findListItems : function ( pattern ) {
76- var matches = pattern . template . match ( this . findListItemsRE ) ;
76+ var matches = pattern . template . match ( findListItemsRE ) ;
7777 return matches ;
7878 } ,
7979
8080 // given a pattern, and a partial string, tease out the "pattern key" and
8181 // return it.
8282 findPartial : function ( partialString ) {
83- var partial = partialString . replace ( this . findPartialsRE , '$1' ) ;
83+ var partial = partialString . replace ( findPartialsRE , '$1' ) ;
8484 return partial ;
8585 }
8686} ;
0 commit comments