Treat nil and empty binaries as false in conditions#51
Merged
soranoba merged 3 commits intoOct 15, 2020
Conversation
soranoba
reviewed
Oct 15, 2020
soranoba
reviewed
Oct 15, 2020
| Result, Value), State); | ||
| _ when Value =:= false -> | ||
| compile_impl(T, Data, Result, State); | ||
| _ when Value =:= nil -> |
Owner
There was a problem hiding this comment.
Does Elixer commonly use nil?
If so, please provide links that it can refer to.
NULL has various notations depending on the language, so I think that it will necessary to consider the validity.
Contributor
Author
There was a problem hiding this comment.
Yes, Elixir's nil is equivalent to NULL (at least in most languages I'm familiar with). https://hexdocs.pm/elixir/Kernel.html#module-truthy-and-falsy-values
Co-authored-by: Hinagiku Soranoba <soranoba@gmail.com>
Owner
|
Thank you for your contribution. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
First, thanks for creating this library! Second, please forgive me -- I work mainly with Elixir, and this is the first time I've written any Erlang. If you have any suggestions on how I can improve this, please let me know.
Most Mustache implementations that I've used in other languages treat
""andnil/null/undefinedthe same asfalsein conditions. For example, if you plug this template into https://mustache.github.io/#demoand put
{"test1": "", "test2": null}into the JSON field, it should render this: