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
Alternate binding syntax #229
Comments
This whole thing is beautiful. For the <div on-born-for-person="animate"/>
<div for-person-on-born="animate"/> So that it doesn't matter which order the |
@nlundquist suggested using <!-- events ($click) -->
<div on:click="method()"/>
<!-- one-way scope to element property {$value}="scopeValue" -->
<input value:from="scopeValue"/>
<!-- one way element property to scope {^$value}="scopeValue" -->
<input value:to="scopeValue"/>
<!-- two-way element property to scope ({$value})="scopeValue" -->
<input value:bind="scopeValue"/> |
That's even better! And would camelCased variables be supported by hyphenation? |
@marshallswain yes, but even without because <my-component someProperty:to="scopeValue"/>
|
I think |
For sure this will improve binding syntax readability too. |
Love the idea and will improve readability! |
|
@pmgmendes the plan is to support this alongside the current syntax, so you could use either one. |
Are we sure that colon-syntax isn't going to interfere with the (probably rare except maybe for SVGs) edge case where someone uses namespaced attributes? Or rather, could @justinbmeyer comment on what it looks like with namespaces? |
I don't think it will interfere with any svg namespaced attributes. I think you have to use |
@bmomberger-bitovi perhaps with
|
I had considered pretty much exactly that syntax, though I was thinking that if we can parse it, |
@James0x57 put together the regular expressions we can use to codemod to the new binding syntax: #264 (comment) when the time comes. |
Created new issues for the last 2 tasks - going to close this. |
- Implement and test functionality, release it in new can-stache-bindings.
- Add documentation for it
- Make a code-mod.
- Update CanJS guides and recipes to use it (will require CanJS pre release)
- Make a release for this and canjs, push out new site.
- Update DoneJS examples to use it.
- deprecate old functionality.
New users can't remember our binding syntaxes. So, I propose we fix them asap. A 2 week sprint to create this and update the docs will make a 10% better CanJS.
Here's an alternate:
I think the bindings above will work great for
can-element
which will have everything on the elements. There will be no need for "view model" bindings.However, to enable this to work for view model bindings, I'll make two proposals:
1. Use
vm
to signal that behavior on a view model2. Use the
vm
if you have one.99% of the time, if you are on a custom element, you want a
vm
binding. So the bindings would check if there is avm
and use that, resulting in:Cool stuff
This might be able to solve some other issues nicely like #6.
This would update
scopeValue
on theenter
event withinput.value
instead of on thechange
event.Other consideration
We now support events like:
What would this look like in the new syntax?
The text was updated successfully, but these errors were encountered: