Implement false for blocks like mustache(.js) and handlebars.java #822
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Essentially I think the following tests should succeed:
Rationale
mustache(5) states
"False Values or Empty Lists
If the person key exists and has a value of false or an empty list, the HTML between the pound and slash will not be displayed."
In javascript 0, NaN and the empty string are false. This is explicitly stated for the Javascript implementation of mustache: https://github.com/janl/mustache.js#false-values-or-empty-lists
(false, undef and empty lists are already interpreted as false in handlebars.js.)
There seem to be a slight disagreement within the moustache community whether the javascript notion of false should be used in all implementation or if you should use the notion for each specific language, but that the implementations in javascript should use the javascript notion of false is clear.
(See discussion in mustache/spec#28 )
It can also be noted that the java implementations of handlebars tries to follow the javascript behavior. The method isEmpty is used to decide if a value is false: https://github.com/jknack/handlebars.java/blob/master/handlebars/src/main/java/com/github/jknack/handlebars/Handlebars.java#L176
So at the moment handlebars.java follows the behaviour of moustache.js but handlebars.js does not. (Something that just bit me...)