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

Returning 0 from a helper displays nothing #1985

Closed
dylanrtt opened this Issue Oct 12, 2015 · 3 comments

Comments

Projects
None yet
5 participants
@dylanrtt
Contributor

dylanrtt commented Oct 12, 2015

Not sure if this has been reported already, but I think returning the number 0 from a helper should display the 0. It currently displays nothing. I'm guessing there is a truthy check on the helper's output.

// when bar is 0
{{ bar }} // prints "0"
{{ myHelper bar }} // blank (myHelper simply returns the value())

http://jsbin.com/helasubejo/edit?html,js,output

@DesignByOnyx

This comment has been minimized.

Show comment
Hide comment
@DesignByOnyx

DesignByOnyx Oct 13, 2015

Contributor

There is a truthy check here: https://github.com/bitovi/canjs/blob/master/view/stache/mustache_core.js#L535

We need to make sure this wouldn't be a breaking change as some authors might return 0 with the intent of give me an empty string.

Contributor

DesignByOnyx commented Oct 13, 2015

There is a truthy check here: https://github.com/bitovi/canjs/blob/master/view/stache/mustache_core.js#L535

We need to make sure this wouldn't be a breaking change as some authors might return 0 with the intent of give me an empty string.

@justinbmeyer

This comment has been minimized.

Show comment
Hide comment
@justinbmeyer

justinbmeyer Oct 13, 2015

Contributor

This is a bug. Returning 0 to get an empty string wouldn't make sense and its not documented that way so it's ok to change prior to 3.0.

Contributor

justinbmeyer commented Oct 13, 2015

This is a bug. Returning 0 to get an empty string wouldn't make sense and its not documented that way so it's ok to change prior to 3.0.

@justinbmeyer justinbmeyer added the bug label Oct 13, 2015

@asavoy

This comment has been minimized.

Show comment
Hide comment
@asavoy

asavoy Oct 13, 2015

Contributor

This would be the stache equivalent to this mustache issue: #1109

Contributor

asavoy commented Oct 13, 2015

This would be the stache equivalent to this mustache issue: #1109

@daffl daffl added this to the 2.3.0 milestone Oct 22, 2015

DesignByOnyx added a commit that referenced this issue Oct 22, 2015

@daffl daffl closed this in #2016 Oct 22, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment