Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

falsey values don't match reference implementation? #38

Open
hasufell opened this issue Nov 1, 2018 · 7 comments
Open

falsey values don't match reference implementation? #38

hasufell opened this issue Nov 1, 2018 · 7 comments

Comments

@hasufell
Copy link

hasufell commented Nov 1, 2018

https://mustache.github.io/#demo if you set "empty": 0 it is still treated as falsey. Afair, this was also the case for hastache. But stache does not.

Note that the spec seems to talk about falsey not false.

https://github.com/mustache/spec/blob/master/specs/sections.yml#L44

@hasufell hasufell changed the title falsely values don't match spec? falsey values don't match spec? Nov 1, 2018
@mrkkrp
Copy link
Collaborator

mrkkrp commented Nov 1, 2018

Where do you see an example in the spec which demands that zero is to be treated as a falsey value? We run all the examples, so if there were such an example, then the test suite would catch it.

@mrkkrp
Copy link
Collaborator

mrkkrp commented Nov 1, 2018

What is not imposed by the spec is left at implementer's discretion. That said, maybe 0 should be treated as a falsey value.

@mrkkrp
Copy link
Collaborator

mrkkrp commented Nov 2, 2018

We need to check what mustache does in this case.

@hasufell
Copy link
Author

hasufell commented Nov 3, 2018

We need to check what mustache does in this case.

Why?

@mrkkrp
Copy link
Collaborator

mrkkrp commented Nov 3, 2018

Just to get an idea of what other implementations in the same language do. I'll mark this as a feature request awaiting PR, it is unlikely that I'll have time or motivation to do the change myself, but you are welcome to try.

@hasufell
Copy link
Author

hasufell commented Nov 3, 2018

The reference implementation appears to be the ruby one:

Which definitely treats 0 as falsey.

So the question is, whether we want to keep underspecified behavior in sync with the reference implementation.

@mrkkrp
Copy link
Collaborator

mrkkrp commented Nov 3, 2018

I'd merge this change.

@hasufell hasufell changed the title falsey values don't match spec? falsey values don't match reference implementation? Nov 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants