Skip to content
This repository was archived by the owner on Dec 10, 2019. It is now read-only.

Commit 0aba5f4

Browse files
committed
Do not expose regexes in API
1 parent 16c2f72 commit 0aba5f4

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

lib/engine_handlebars.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@
2424

2525
var Handlebars = require('handlebars');
2626

27+
// regexes, stored here so they're only compiled once
28+
const findPartialsRE = /{{#?>\s*([\w-\/.]+)(?:.|\s+)*?}}/g;
29+
const findListItemsRE = /({{#( )?)(list(I|i)tems.)(one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|thirteen|fourteen|fifteen|sixteen|seventeen|eighteen|nineteen|twenty)( )?}}/g;
30+
2731
var 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: /({{#( )?)(list(I|i)tems.)(one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|thirteen|fourteen|fifteen|sixteen|seventeen|eighteen|nineteen|twenty)( )?}}/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

Comments
 (0)