File tree Expand file tree Collapse file tree 2 files changed +9
-6
lines changed Expand file tree Collapse file tree 2 files changed +9
-6
lines changed Original file line number Diff line number Diff line change 21
21
function findparameters ( pattern , patternlab ) {
22
22
23
23
//find the {{> template-name(*) }} within patterns
24
- var matches = pattern . template . match ( / { { > ( [ ] + ) ? ( [ A - Z a - z 0 - 9 - ] + ) ( \( ) ( .+ ) ( \) ) ( [ ] + ) ? } } / g) ;
24
+ var matches = pattern . template . match ( / { { > ( [ ] + ) ? ( [ \w \- \. \/ ~ ] + ) ( \( ) ( .+ ) ( \) ) ( [ ] + ) ? } } / g) ;
25
25
if ( matches !== null ) {
26
26
//compile this partial immeadiately, essentially consuming it.
27
27
matches . forEach ( function ( pMatch , index , matches ) {
28
28
//find the partial's name
29
- var partialName = pMatch . match ( / ( [ a - z - ] + ) / ig ) [ 0 ] ;
29
+ var partialName = pMatch . match ( / ( [ \w \- \. \/ ~ ] + ) / g ) [ 0 ] ;
30
30
31
31
if ( patternlab . config . debug ) {
32
32
console . log ( 'found patternParameters for ' + partialName ) ;
Original file line number Diff line number Diff line change 25
25
26
26
//find and return any {{> template-name }} within pattern
27
27
function findPartials ( pattern ) {
28
- var matches = pattern . template . match ( / { { > ( [ ] ) ? ( [ A - Z a - z 0 - 9 - ] + ) (?: \: [ A - Z a - z 0 - 9 - ] + ) ? (?: ( | ) \( .* ) ? ( [ ] ) ? } } / g) ;
28
+ var matches = pattern . template . match ( / { { > ( [ ] ) ? ( [ \w \- \. \/ ~ ] + ) (?: \: [ A - Z a - z 0 - 9 - ] + ) ? (?: ( | ) \( .* ) ? ( [ ] ) ? } } / g) ;
29
29
return matches ;
30
30
}
31
31
138
138
139
139
//do something with the regular old partials
140
140
for ( var i = 0 ; i < foundPatternPartials . length ; i ++ ) {
141
- var partialKey = foundPatternPartials [ i ] . replace ( / { { > ( [ ] ) ? ( [ A - Z a - z 0 - 9 - ] + ) (?: \: [ A - Z a - z 0 - 9 - ] + ) ? (?: ( | ) \( .* ) ? ( [ ] ) ? } } / g, '$2' ) ;
141
+ var partialKey = foundPatternPartials [ i ] . replace ( / { { > ( [ ] ) ? ( [ \w \- \. \/ ~ ] + ) (?: \: [ A - Z a - z 0 - 9 - ] + ) ? (?: ( | ) \( .* ) ? ( [ ] ) ? } } / g, '$2' ) ;
142
142
var partialPattern = getpatternbykey ( partialKey , patternlab ) ;
143
143
currentPattern . extendedTemplate = currentPattern . extendedTemplate . replace ( foundPatternPartials [ i ] , partialPattern . extendedTemplate ) ;
144
144
}
157
157
158
158
function getpatternbykey ( key , patternlab ) {
159
159
for ( var i = 0 ; i < patternlab . patterns . length ; i ++ ) {
160
- if ( patternlab . patterns [ i ] . key === key ) {
161
- return patternlab . patterns [ i ] ;
160
+ switch ( key ) {
161
+ case patternlab . patterns [ i ] . key :
162
+ case patternlab . patterns [ i ] . subdir + '/' + patternlab . patterns [ i ] . fileName :
163
+ case patternlab . patterns [ i ] . subdir + '/' + patternlab . patterns [ i ] . fileName + '.mustache' :
164
+ return patternlab . patterns [ i ] ;
162
165
}
163
166
}
164
167
throw 'Could not find pattern with key ' + key ;
You can’t perform that action at this time.
0 commit comments