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

can.mustache: {{else}} does not work for {{#unless}} block #988

Closed
isadovskiy opened this Issue May 14, 2014 · 4 comments

Comments

Projects
None yet
4 participants
@isadovskiy

isadovskiy commented May 14, 2014

I was able to get {{else}} block works in Mustache template in CanJS 2.0.5 within {{#if}} blocks and user-defined helpers. However can't get it work within {{#unless}} block. Everything inside {{else}} part of the block is ignored and not rendered.

See http://jsfiddle.net/7NJjt/1/

@ccummings ccummings added the Bug label May 16, 2014

@andrew-sygyda

This comment has been minimized.

Show comment
Hide comment
@andrew-sygyda

andrew-sygyda May 19, 2014

This is not a bug, becouse helper {{else}} use only with helper {{#if}}.

andrew-sygyda commented May 19, 2014

This is not a bug, becouse helper {{else}} use only with helper {{#if}}.

@isadovskiy

This comment has been minimized.

Show comment
Hide comment
@isadovskiy

isadovskiy May 19, 2014

According to docs, {{else}} should work with any helper, which starts with # (http://canjs.com/docs/can.mustache.helpers.else.html), including user-defined helpers. And it works. Except for {{unless}}.

isadovskiy commented May 19, 2014

According to docs, {{else}} should work with any helper, which starts with # (http://canjs.com/docs/can.mustache.helpers.else.html), including user-defined helpers. And it works. Except for {{unless}}.

@andrew-sygyda

This comment has been minimized.

Show comment
Hide comment
@andrew-sygyda

andrew-sygyda May 19, 2014

According to source code:
'unless': function (expr, options) {
if (!Mustache.resolve(expr)) {
return options.fn(options.contexts || this);
}
}
Does not have "options.inverse" branch. So thats why {{else}} not working.

andrew-sygyda commented May 19, 2014

According to source code:
'unless': function (expr, options) {
if (!Mustache.resolve(expr)) {
return options.fn(options.contexts || this);
}
}
Does not have "options.inverse" branch. So thats why {{else}} not working.

@justinbmeyer

This comment has been minimized.

Show comment
Hide comment
@justinbmeyer

justinbmeyer May 19, 2014

Contributor

Yeah, this should be fixed.

Contributor

justinbmeyer commented May 19, 2014

Yeah, this should be fixed.

@justinbmeyer justinbmeyer added this to the 2.1.1 milestone May 19, 2014

@ccummings ccummings closed this in #1004 May 20, 2014

ccummings added a commit that referenced this issue May 20, 2014

Merge pull request #1004 from bitovi/988-fix-else-unless
Fixing unless helper to work with else. Fixes #988

gsmeets pushed a commit to gsmeets/canjs that referenced this issue Aug 15, 2014

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