-
Notifications
You must be signed in to change notification settings - Fork 12
add documentation for data helper #574
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
Conversation
|
||
@param {String} name The name of the data attribute to use for the | ||
context. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably need to add a param for key
:
@param {String} [key] An optional key used to specify what data should be stored in [can-dom-data]. It defaults to the context (`this`) if no key is specified.
@@ -0,0 +1,26 @@ | |||
@function can-stache.helpers.data {{data name}} | |||
@parent can-stache.htags 7 | |||
@signature `{{data name[ key]}}` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this indeed the signature? Might it be {{data [key] name}}
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not. Don't worry about this.
It is common to want some data in the template to be available | ||
on an element. `{{data name}}` allows you to save the | ||
context so it can later be retrieved by [can.data] or | ||
`$.fn.data`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think $.fn.data works anymore.
context so it can later be retrieved by [can.data] or | ||
`$.fn.data`. | ||
|
||
<a class="jsbin-embed" href="http://jsbin.com/juxem/latest/embed?html,js,output">JS Bin</a><script src="http://static.jsbin.com/js/embed.js"></script> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably get rid of this or make a code sample that is @codepen
-able.
|
||
By passing a key name as the second argument to the data helper, you can specify which data is used: `{{data name key}}`. | ||
|
||
<a class="jsbin-embed" href="http://jsbin.com/munuco/latest/embed?html,js,output">JS Bin</a><script src="http://static.jsbin.com/js/embed.js"></script> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this is super old example, remove it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The data
helper was replaced with domData in can-stache 4.3.
Do we still want to add docs for the deprecated API? Or should this be for the 3.x docs (where data
was never documented)?
Migrate over {{data name}} data helper documentation from 2.0 to current docs. Addresses issue #199