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

Mustache {{#if}} does not correctly evaluate boolean value #333

Closed
foxdonut opened this issue Mar 22, 2013 · 2 comments
Closed

Mustache {{#if}} does not correctly evaluate boolean value #333

foxdonut opened this issue Mar 22, 2013 · 2 comments
Milestone

Comments

@foxdonut
Copy link

Please refer to:
http://jsfiddle.net/foxdonut/AUZmf/

{{hasDucks}} evaluates to false, but {{#if}} considers it true, displaying "Ducks:". Instead, it should display "No ducks!"

@ghost ghost assigned andykant Mar 22, 2013
@bmomberger-reciprocity
Copy link
Contributor

It works if you make it a can.compute.

http://jsfiddle.net/AUZmf/10/

This relates to the fix I made for #292. I only considered computes and not other functions. A non-compute function is treated as a static value when it's an argument to a helper, and function objects are truthy.

andykant added a commit that referenced this issue Mar 24, 2013
…equivalent, updated all default helpers accordingly #333
andykant added a commit that referenced this issue Mar 24, 2013
Added Mustache.resolve to evaluate truthyness in a common way #333
@andykant
Copy link
Contributor

Added Mustache.resolve that'll resolve any variable the same way it would normally be interpolated and updated the default helpers to use this for evaluating truthyness.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants