File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -989,11 +989,14 @@ lib.templateString = function(string, obj) {
989989 var getterCache = { } ;
990990
991991 return string . replace ( lib . TEMPLATE_STRING_REGEX , function ( dummy , key ) {
992+ var v ;
992993 if ( SIMPLE_PROPERTY_REGEX . test ( key ) ) {
993- return obj [ key ] || '' ;
994+ v = obj [ key ] ;
995+ } else {
996+ getterCache [ key ] = getterCache [ key ] || lib . nestedProperty ( obj , key ) . get ;
997+ v = getterCache [ key ] ( ) ;
994998 }
995- getterCache [ key ] = getterCache [ key ] || lib . nestedProperty ( obj , key ) . get ;
996- return getterCache [ key ] ( ) || '' ;
999+ return lib . isValidTextValue ( v ) ? v : '' ;
9971000 } ) ;
9981001} ;
9991002
Original file line number Diff line number Diff line change @@ -2229,6 +2229,14 @@ describe('Test lib.js:', function() {
22292229 it ( 'replaces empty key with empty string' , function ( ) {
22302230 expect ( Lib . templateString ( 'foo %{} %{}' , { } ) ) . toEqual ( 'foo ' ) ;
22312231 } ) ;
2232+
2233+ it ( 'should work with the number *0*' , function ( ) {
2234+ expect ( Lib . templateString ( '%{group}' , { group : 0 } ) ) . toEqual ( '0' ) ;
2235+ } ) ;
2236+
2237+ it ( 'should work with the number *0* (nested case)' , function ( ) {
2238+ expect ( Lib . templateString ( '%{x.y}' , { 'x' : { y : 0 } } ) ) . toEqual ( '0' ) ;
2239+ } ) ;
22322240 } ) ;
22332241
22342242 describe ( 'hovertemplateString' , function ( ) {
You can’t perform that action at this time.
0 commit comments