File tree Expand file tree Collapse file tree 1 file changed +18
-9
lines changed
Expand file tree Collapse file tree 1 file changed +18
-9
lines changed Original file line number Diff line number Diff line change 230230 toInject . set ( rawToken , content ) ;
231231 } ;
232232
233- // Fill template placeholders. Return falsy if:
234- // - At least one argument contains anything else than /\w/ and `.`
235-
233+ // Fill-in scriptlet argument placeholders.
236234 const patchScriptlet = function ( content , args ) {
235+ let s = args ;
236+ let len = s . length ;
237+ let beg = 0 , pos = 0 ;
237238 let i = 1 ;
238- while ( args !== '' ) {
239- let pos = args . indexOf ( ',' ) ;
240- if ( pos === - 1 ) { pos = args . length ; }
241- const arg = args . slice ( 0 , pos ) . trim ( ) . replace ( reEscapeScriptArg , '\\$&' ) ;
242- content = content . replace ( `{{${ i } }}` , arg ) ;
243- args = args . slice ( pos + 1 ) . trim ( ) ;
239+ while ( beg < len ) {
240+ pos = s . indexOf ( ',' , pos ) ;
241+ // Escaped comma? If so, skip.
242+ if ( pos > 0 && s . charCodeAt ( pos - 1 ) === 0x5C /* '\\' */ ) {
243+ s = s . slice ( 0 , pos - 1 ) + s . slice ( pos ) ;
244+ len -= 1 ;
245+ continue ;
246+ }
247+ if ( pos === - 1 ) { pos = len ; }
248+ content = content . replace (
249+ `{{${ i } }}` ,
250+ s . slice ( beg , pos ) . trim ( ) . replace ( reEscapeScriptArg , '\\$&' )
251+ ) ;
252+ beg = pos = pos + 1 ;
244253 i ++ ;
245254 }
246255 return content ;
You can’t perform that action at this time.
0 commit comments