Skip to content
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

Added to EventContext.renderEach documentation #231

Merged
merged 2 commits into from Aug 26, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 12 additions & 1 deletion lib/sammy.js
Expand Up @@ -2025,7 +2025,14 @@ $.extend(Sammy.DefaultLocationProxy.prototype , {

// Create and return a `Sammy.RenderContext` calling `renderEach()` on it.
// Loads the template and interpolates the data for each item,
// however does not actual place it in the DOM.
// however does not actually place it in the DOM.
//
// `name` is an optional parameter (if it is an array, it is used as `data`,
// and the third parameter used as `callback`, if set).
//
// If `data` is not provided, content from the previous step in the chain
// (if it is an array) is used, and `name` is used as the key for each
// element of the array (useful for referencing in template).
//
// ### Example
//
Expand All @@ -2035,6 +2042,10 @@ $.extend(Sammy.DefaultLocationProxy.prototype , {
// renderEach('mytemplate.mustache', [{name: 'quirkey'}, {name: 'endor'}]).appendTo('ul');
// // appends the rendered content to $('ul')
//
// // names.json: ['quirkey', 'endor']
// this.load('names.json').renderEach('mytemplate.mustache', 'name').appendTo('ul');
// // uses the template to render each item in the JSON array
//
renderEach: function(location, name, data, callback) {
return new Sammy.RenderContext(this).renderEach(location, name, data, callback);
},
Expand Down