Skip to content

Conversation

@mcampa
Copy link
Contributor

@mcampa mcampa commented Sep 15, 2017

Customers are trying to use "unless" with operators, the same way "if" works, but we have not implemented this helper.

@bigcommerce/stencil-team

}
} else { // non-block helper
return result;
if (!options.fn || !options.inverse) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is changing the behavior for if when fn is not passed. Instead of returning the value, we return true. Is that what we want?

Copy link
Contributor Author

@mcampa mcampa Sep 15, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No is not, there are tests in place for these cases. This code was added in the wrong way a few moths ago a12cdbd

I had to change it because it was breaking when if is called from unless helper because the unless helper relies in fn() and inverse()

Copy link
Contributor Author

@mcampa mcampa Sep 15, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The return values is always a boolean when called from a non-block

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to pass fn but not inverse? Should this be

options.fn = typeof options.fn === 'function' ? options.fn : () => true;
options.inverse = typeof options.inverse === 'function' ? options.inverse : () => false;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

both need to exist. If one of them is missing, is probably a bug

@mcampa mcampa merged commit f4280b0 into bigcommerce:master Sep 15, 2017
@mcampa mcampa deleted the STENCIL-3845-unless-helper branch September 15, 2017 19:34
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

Successfully merging this pull request may close these issues.

2 participants