diff --git a/mustache.js b/mustache.js index 641cebd57..38dab6a10 100644 --- a/mustache.js +++ b/mustache.js @@ -175,7 +175,7 @@ var Mustache = (typeof module !== "undefined" && module.exports) || {}; // From the spec: inverted sections may render text once based on the // inverse value of the key. That is, they will be rendered if the key // doesn't exist, is false, or is an empty list. - if (value == null || value === false || (isArray(value) && value.length === 0)) { + if (!value || (isArray(value) && value.length === 0)) { buffer += callback(); } } else if (isArray(value)) { diff --git a/spec/_files/inverted_section.js b/spec/_files/inverted_section.js index 2e07fc3a2..0bf7f4c06 100644 --- a/spec/_files/inverted_section.js +++ b/spec/_files/inverted_section.js @@ -1,3 +1,4 @@ var inverted_section = { - "repos": [] + "repos": [], + "empty_string": "" }; diff --git a/spec/_files/inverted_section.mustache b/spec/_files/inverted_section.mustache index b0a183b10..348e84c3a 100644 --- a/spec/_files/inverted_section.mustache +++ b/spec/_files/inverted_section.mustache @@ -1,3 +1,4 @@ {{#repos}}{{name}}{{/repos}} {{^repos}}No repos :({{/repos}} {{^nothin}}Hello!{{/nothin}} +{{^empty_string}}Empty string should be falsey{{/empty_string}} \ No newline at end of file diff --git a/spec/_files/inverted_section.txt b/spec/_files/inverted_section.txt index b421582e7..80f50a8da 100644 --- a/spec/_files/inverted_section.txt +++ b/spec/_files/inverted_section.txt @@ -1,3 +1,4 @@ No repos :( Hello! +Empty string should be falsey \ No newline at end of file