Skip to content

Conversation

michaelzcheng
Copy link
Contributor

@michaelzcheng michaelzcheng commented Jul 26, 2018

Migrate over {{data name}} data helper documentation from 2.0 to current docs. Addresses issue #199


@param {String} name The name of the data attribute to use for the
context.

Copy link
Contributor

@justinbmeyer justinbmeyer Jul 27, 2018

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]}}`
Copy link
Contributor

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}}?

Copy link
Contributor

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`.
Copy link
Contributor

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>
Copy link
Contributor

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>
Copy link
Contributor

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.

Copy link
Contributor

@justinbmeyer justinbmeyer left a comment

Choose a reason for hiding this comment

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

Added comments.

Copy link
Member

@chasenlehara chasenlehara left a 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)?

@Amechi101 Amechi101 merged commit 1c4a48c into master May 16, 2019
Amechi101 pushed a commit that referenced this pull request May 16, 2019
Amechi101 pushed a commit that referenced this pull request May 16, 2019
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.

5 participants