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

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

Comments

Projects
None yet
3 participants
@foxdonut

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

This comment has been minimized.

Show comment
Hide comment
@bmomberger-reciprocity

bmomberger-reciprocity Mar 22, 2013

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.

Contributor

bmomberger-reciprocity commented Mar 22, 2013

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

Added Mustache.resolve method that evaluates objects to their truthy …
…equivalent, updated all default helpers accordingly #333

andykant added a commit that referenced this issue Mar 24, 2013

Merge pull request #335 from bitovi/default-helpers-resolve-333
Added Mustache.resolve to evaluate truthyness in a common way #333
@andykant

This comment has been minimized.

Show comment
Hide comment
@andykant

andykant Mar 24, 2013

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.

Contributor

andykant commented Mar 24, 2013

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