• function

{{data name}} can.Mustache.helpers.data


{{data name}}

Adds the current context to the element's can.data.


  1. name {String}

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


Its common you 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. For example,

The template:

  <li id="person" {{data 'person'}}>{{name}}</li>

Rendered with:

  can.view.mustache(template,{ person: { name: 'Austin' } });

Retrieve the person data back with: