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

stache.registerConverter function #35

Merged
merged 1 commit into from
Aug 1, 2016
Merged

Conversation

bmomberger-bitovi
Copy link
Contributor

registerConverter() is a wrapper around helpers used in a Call expression. When it detects it's being called by a compute's setter, it calls the supplied set() function. Otherwise it calls get().


helpers.registerConverter('isInList', {
get: function(valCompute, list) {
return !!~list.indexOf(valCompute());
Copy link
Contributor

Choose a reason for hiding this comment

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

Haven't seen that clever shorthand before -- cool 😃

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you'd believe it, I learned that from reading the CanJS source code.

Copy link
Contributor

Choose a reason for hiding this comment

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

I was into it for a while, but it's confusing to a new person so I've stopped using it as much.

@matthewp
Copy link
Contributor

cc @justinbmeyer to review.

@@ -0,0 +1,39 @@
@typedef {{get:can-stache.helper,set:function(*,can-compute...){}}} can-stache.getterSetter getterSetter
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm going to move this to a .md. That's where everything else has its docs.

@justinbmeyer justinbmeyer self-assigned this Aug 1, 2016
@justinbmeyer justinbmeyer merged commit 1b240d9 into master Aug 1, 2016
@justinbmeyer justinbmeyer deleted the stache-converter branch August 1, 2016 22:36
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.

4 participants