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

Commit db9eba3

Browse files
author
Brian Muenzenmeyer
authored
Merge pull request #1 from pattern-lab/dev
alter findPartials regex to a modified version of the old format
2 parents 6390e2c + 01732b1 commit db9eba3

File tree

4 files changed

+7
-60
lines changed

4 files changed

+7
-60
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
## The Mustache engine for Pattern Lab / Node
22

3-
This one should be included by default with Mustache editions. If it's missing from your project for any reason, `npm install patternengine-node-mustache` should do the trick.
3+
This one should be included by default with [Pattern Lab Node Core](https://github.com/pattern-lab/patternlab-node) and consumed by [Node Editions](https://github.com/pattern-lab?utf8=%E2%9C%93&query=edition-node).
44

5-
On dev right now the command is `npm install pattern-lab/patternengine-node-mustache#dev`
5+
If it's missing from your project for any reason, `npm install patternengine-node-mustache` should do the trick.

lib/engine_mustache.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* mustache pattern engine for patternlab-node - v0.10.1 - 2015
2+
* mustache pattern engine for patternlab-node - v2.X.X - 2016
33
*
44
* Geoffrey Pursell, Brian Muenzenmeyer, and the web community.
55
* Licensed under the MIT license.
@@ -60,13 +60,11 @@ var engine_mustache = {
6060
*/
6161
patternMatcher: function patternMatcher(pattern, regex) {
6262
var matches;
63-
6463
if (typeof pattern === 'string') {
6564
matches = pattern.match(regex);
6665
} else if (typeof pattern === 'object' && typeof pattern.template === 'string') {
6766
matches = pattern.template.match(regex);
6867
}
69-
7068
return matches;
7169
},
7270

lib/util_mustache.js

Lines changed: 3 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* mustache utilities for patternlab-node - v0.10.1 - 2015
2+
* mustache utilities for patternlab-node - v2.X.X - 2016
33
*
44
* Geoffrey Pursell, Brian Muenzenmeyer, and the web community.
55
* Licensed under the MIT license.
@@ -12,59 +12,8 @@
1212

1313
// the term "alphanumeric" includes underscores.
1414

15-
// look for an opening mustache include tag, followed by >=0 whitespaces
16-
var partialsStr = '{{>\\s*';
17-
18-
// begin 1st exterior group, a mandatory group
19-
// look for >0 of an interior group comprising
20-
// >0 digits, followed by a hyphen, followed by >0 alphanumerics
21-
partialsStr += '((\\d+-[\\w-]+\\/)+';
22-
23-
// then an interior group comprising
24-
// >0 digits, followed by a hyphen, followed by >0 alphanumerics,
25-
// followed by an optional group of a period followed by >0 alphanumerics
26-
partialsStr += '(\\d+-[\\w-]+(\\.\\w+)?)';
27-
28-
// if the previous two interior groups are not found, look for any number of
29-
// alphanumerics or hyphens
30-
partialsStr += '|[\\w\\-]+)';
31-
32-
// end 1st exterior group
33-
// begin 2nd exterior group, an optional group
34-
// look for a colon, followed by >0 alphanumerics or hyphens,
35-
// followed by >=0 interior groups
36-
// comprising a pipe, followed by >0 alphanumerics or hyphens
37-
partialsStr += '(\\:[\\w\\-]+(\\|[\\w\\-]+)*)?';
38-
39-
// end 2nd exterior group
40-
// begin 3rd exterior group, an optional group
41-
// look for an opening parenthesis, followed by >=0 whitespaces, followed by
42-
// >0 alphanumerics, followed by >=0 whitespaces, followed by a colon,
43-
// followed by >=0 whitespaces
44-
partialsStr += '(\\(\\s*\\w+\\s*\\:\\s*';
45-
46-
// followed by an interior group
47-
// comprising a single quote, followed by an interior group comprising
48-
// >=0 characters that are not single quotes or backslashes
49-
// or >=0 character pairs comprising a backlash, followed by any character.
50-
// look for a single quote to terminate this pattern
51-
partialsStr += '(\'([^\'\\\\]|\\\\.)*\'';
52-
53-
// if the pattern wrapped in single quotes is not found, look for one wrapped
54-
// in double quotes
55-
// look for a double quote, followed by an interior group comprising
56-
// >=0 characters that are not double quotes or backslashes
57-
// or >=0 character pairs comprising a backlash, followed by any character.
58-
// look for a double quote to terminate this pattern
59-
partialsStr += '|"([^"\\\\]|\\\\.)*")';
60-
61-
// look for a closing parenthesis
62-
partialsStr += '\\))?';
63-
64-
// end 3rd exterior group
65-
// look for >=0 whitespaces, followed by closing mustache tag
66-
partialsStr += '\\s*}}';
67-
var partialsRE = new RegExp(partialsStr, 'g');
15+
// todo: document this exact regex long form.
16+
var partialsRE = new RegExp(/{{>\s*?([\w\-\.\/~]+)(?:\:[A-Za-z0-9-_|]+)?(?:(?:| )\(.*)?(?:\s*)?}}/, 'g');
6817

6918
// look for an opening mustache include tag, followed by >=0 whitespaces
7019
var partialsWithStyleModifiersStr = '{{>\\s*';

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "patternengine-node-mustache",
33
"description": "The Mustache engine for Pattern Lab / Node",
4-
"version": "1.0.0",
4+
"version": "1.0.1",
55
"main": "lib/engine_mustache.js",
66
"dependencies": {
77
"mustache": "^2.2.0"

0 commit comments

Comments
 (0)