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

Commit 3df9420

Browse files
author
e2tha-e
committed
updating function name and docblock
1 parent 2f183dc commit 3df9420

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

core/lib/pattern_engines/engine_mustache.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,15 @@ var engine_mustache = {
4646
return Mustache.render(template, data);
4747
},
4848

49-
// find partials based on regex.
50-
// @param {string|object} pattern - either a string or a pattern object.
51-
// @param {object} regex - a JavaScript RegExp object.
52-
// @returns {array}
53-
partialsFinder: function partialsFinder(pattern, regex) {
54-
var matches = [];
49+
/**
50+
* Find regex matches within both pattern strings and pattern objects.
51+
*
52+
* @param {string|object} pattern Either a string or a pattern object.
53+
* @param {object} regex A JavaScript RegExp object.
54+
* @returns {array|null} An array if a match is found, null if not.
55+
*/
56+
patternMatcher: function patternMatcher(pattern, regex) {
57+
var matches;
5558

5659
if (typeof pattern === 'string') {
5760
matches = pattern.match(regex);
@@ -64,22 +67,22 @@ var engine_mustache = {
6467

6568
// find and return any {{> template-name }} within pattern
6669
findPartials: function findPartials(pattern) {
67-
var matches = this.partialsFinder(pattern, this.findPartialsRE);
70+
var matches = this.patternMatcher(pattern, this.findPartialsRE);
6871
return matches;
6972
},
7073
findPartialsWithStyleModifiers: function (pattern) {
71-
var matches = this.partialsFinder(pattern, this.findPartialsWithStyleModifiersRE);
74+
var matches = this.patternMatcher(pattern, this.findPartialsWithStyleModifiersRE);
7275
return matches;
7376
},
7477

7578
// returns any patterns that match {{> value(foo:"bar") }} or {{>
7679
// value:mod(foo:"bar") }} within the pattern
7780
findPartialsWithPatternParameters: function (pattern) {
78-
var matches = this.partialsFinder(pattern, this.findPartialsWithPatternParametersRE);
81+
var matches = this.patternMatcher(pattern, this.findPartialsWithPatternParametersRE);
7982
return matches;
8083
},
8184
findListItems: function (pattern) {
82-
var matches = this.partialsFinder(pattern, this.findListItemsRE);
85+
var matches = this.patternMatcher(pattern, this.findListItemsRE);
8386
return matches;
8487
},
8588

0 commit comments

Comments
 (0)