|
1 | 1 | /*
|
2 |
| - * mustache utilities for patternlab-node - v0.10.1 - 2015 |
| 2 | + * mustache utilities for patternlab-node - v2.X.X - 2016 |
3 | 3 | *
|
4 | 4 | * Geoffrey Pursell, Brian Muenzenmeyer, and the web community.
|
5 | 5 | * Licensed under the MIT license.
|
|
12 | 12 |
|
13 | 13 | // the term "alphanumeric" includes underscores.
|
14 | 14 |
|
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'); |
68 | 17 |
|
69 | 18 | // look for an opening mustache include tag, followed by >=0 whitespaces
|
70 | 19 | var partialsWithStyleModifiersStr = '{{>\\s*';
|
|
0 commit comments