stache icon indicating copy to clipboard operation
stache copied to clipboard

falsey values don't match reference implementation?

Open hasufell opened this issue 7 years ago • 7 comments

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 avatar Nov 01 '18 09:11 hasufell

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 avatar Nov 01 '18 16:11 mrkkrp

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 avatar Nov 01 '18 16:11 mrkkrp

We need to check what mustache does in this case.

mrkkrp avatar Nov 02 '18 16:11 mrkkrp

We need to check what mustache does in this case.

Why?

hasufell avatar Nov 03 '18 06:11 hasufell

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.

mrkkrp avatar Nov 03 '18 06:11 mrkkrp

The reference implementation appears to be the ruby one:

  • https://github.com/mustache/mustache
  • https://mustache.github.io/mustache.1.html

Which definitely treats 0 as falsey.

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

hasufell avatar Nov 03 '18 07:11 hasufell

I'd merge this change.

mrkkrp avatar Nov 03 '18 07:11 mrkkrp