@@ -14,8 +14,8 @@ var Mustache = (typeof module !== "undefined" && module.exports) || {};
1414 exports . render = render ;
1515 exports . clearCache = clearCache ;
1616
17- // This is here for backwards compatibility with 0.4.x.
18- exports . to_html = function ( template , view , partials , send ) {
17+ // This is here for backwards compatibility with 0.4.x.
18+ exports . to_html = function ( template , view , partials , send ) { // jshint ignore:line
1919 var result = render ( template , view , partials ) ;
2020
2121 if ( typeof send === "function" ) {
@@ -61,7 +61,7 @@ var Mustache = (typeof module !== "undefined" && module.exports) || {};
6161 var trim ;
6262 if ( _trim ) {
6363 trim = function ( string ) {
64- return string == null ? "" : _trim . call ( string ) ;
64+ return string === null || string === undefined ? "" : _trim . call ( string ) ;
6565 } ;
6666 } else {
6767 var trimLeft , trimRight ;
@@ -76,7 +76,7 @@ var Mustache = (typeof module !== "undefined" && module.exports) || {};
7676 }
7777
7878 trim = function ( string ) {
79- return string == null ? "" :
79+ return string === null || string === undefined ? "" :
8080 String ( string ) . replace ( trimLeft , "" ) . replace ( trimRight , "" ) ;
8181 } ;
8282 }
@@ -142,7 +142,7 @@ var Mustache = (typeof module !== "undefined" && module.exports) || {};
142142 while ( j < lastIndex ) {
143143 context = context [ names [ j ++ ] ] ;
144144
145- if ( context == null ) {
145+ if ( context === null || context === undefined ) {
146146 break ;
147147 }
148148
@@ -160,7 +160,7 @@ var Mustache = (typeof module !== "undefined" && module.exports) || {};
160160 value = value . call ( localStack [ localStack . length - 1 ] ) ;
161161 }
162162
163- if ( value == null ) {
163+ if ( value === null || value === undefined ) {
164164 return defaultValue ;
165165 }
166166
@@ -175,7 +175,7 @@ var Mustache = (typeof module !== "undefined" && module.exports) || {};
175175 // From the spec: inverted sections may render text once based on the
176176 // inverse value of the key. That is, they will be rendered if the key
177177 // doesn't exist, is false, or is an empty list.
178- if ( value == null || value === false || ( isArray ( value ) && value . length === 0 ) ) {
178+ if ( value === null || value === undefined || value === false || ( isArray ( value ) && value . length === 0 ) ) {
179179 buffer += callback ( ) ;
180180 }
181181 } else if ( isArray ( value ) ) {
@@ -294,9 +294,9 @@ var Mustache = (typeof module !== "undefined" && module.exports) || {};
294294
295295 var closeSection = function ( source ) {
296296 var name = trim ( source ) ;
297- var openName = sectionStack . length != 0 && sectionStack [ sectionStack . length - 1 ] . name ;
297+ var openName = sectionStack . length !== 0 && sectionStack [ sectionStack . length - 1 ] . name ;
298298
299- if ( ! openName || name != openName ) {
299+ if ( ! openName || name !== openName ) {
300300 throw debug ( new Error ( 'Section named "' + name + '" was never opened' ) , template , line , options . file ) ;
301301 }
302302
@@ -373,7 +373,7 @@ var Mustache = (typeof module !== "undefined" && module.exports) || {};
373373 callback = closeSection ;
374374 break ;
375375 case "{" : // plain variable
376- closeTag = "}" + closeTag ;
376+ closeTag = "}" + closeTag ; // jshint ignore:line
377377 // fall through
378378 case "&" : // plain variable
379379 i ++ ;
@@ -399,7 +399,7 @@ var Mustache = (typeof module !== "undefined" && module.exports) || {};
399399
400400 // Maintain line count for \n in source.
401401 var n = 0 ;
402- while ( ~ ( n = source . indexOf ( "\n" , n ) ) ) {
402+ while ( ~ ( n = source . indexOf ( "\n" , n ) ) ) { // jshint ignore:line
403403 line ++ ;
404404 n ++ ;
405405 }
@@ -437,7 +437,7 @@ var Mustache = (typeof module !== "undefined" && module.exports) || {};
437437 }
438438 }
439439
440- if ( sectionStack . length != 0 ) {
440+ if ( sectionStack . length !== 0 ) {
441441 throw debug ( new Error ( 'Section "' + sectionStack [ sectionStack . length - 1 ] . name + '" was not closed properly' ) , template , line , options . file ) ;
442442 }
443443
@@ -455,7 +455,7 @@ var Mustache = (typeof module !== "undefined" && module.exports) || {};
455455 var body = code . join ( "" ) . replace ( / b u f f e r \+ = " " ; \n / g, "" ) ;
456456
457457 if ( options . debug ) {
458- if ( typeof console != "undefined" && console . log ) {
458+ if ( typeof console !== "undefined" && console . log ) {
459459 console . log ( body ) ;
460460 } else if ( typeof print === "function" ) {
461461 print ( body ) ;
@@ -471,7 +471,7 @@ var Mustache = (typeof module !== "undefined" && module.exports) || {};
471471 function _compile ( template , options ) {
472472 var args = "view,partials,stack,lookup,escapeHTML,renderSection,render" ;
473473 var body = parse ( template , options ) ;
474- var fn = new Function ( args , body ) ;
474+ var fn = new Function ( args , body ) ; // jshint ignore:line
475475
476476 // This anonymous function wraps the generated function so we can do
477477 // argument coercion, setup some variables, and handle any errors
0 commit comments