{{data name}}

  • function
can.stache.helpers.data  

{{data name[ key]}}

Adds the current [can.stache.context context] to the element's can.data.

Parameters

  1. name {String}

    The name of the data attribute to use for the context.

Use

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.

JS Bin

Getting more specific

By passing a key name as the second argument to the data helper, you can specify which data is used: {{data name key}}.

JS Bin