File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -418,8 +418,8 @@ string.js - Copyright (C) 2012-2014, JP Richardson <
[email protected] >
418
418
419
419
matches . forEach ( function ( match ) {
420
420
var key = match . substring ( opening . length , match . length - closing . length ) . trim ( ) ; //chop {{ and }}
421
- if ( typeof values [ key ] != 'undefined' )
422
- s = s . replace ( match , values [ key ] ) ;
421
+ var value = typeof values [ key ] == 'undefined' ? '' : values [ key ] ;
422
+ s = s . replace ( match , value ) ;
423
423
} ) ;
424
424
return new this . constructor ( s ) ;
425
425
} ,
Original file line number Diff line number Diff line change 547
547
EQ ( S ( str ) . template ( values ) . s , "Hello " )
548
548
} )
549
549
} )
550
+
551
+ describe ( '> when a key does not exist' , function ( ) {
552
+ it ( 'should still replace with the empty value' , function ( ) {
553
+ S . TMPL_OPEN = '{{'
554
+ S . TMPL_CLOSE = '}}'
555
+ var str = "Hello {{name}}"
556
+ var values = { }
557
+ EQ ( S ( str ) . template ( values ) . s , "Hello " )
558
+ } )
559
+ } )
550
560
} )
551
561
552
562
describe ( '- times(n)' , function ( ) {
You can’t perform that action at this time.
0 commit comments