rendr-handlebars
Version:
Glue handlebars templates into a Rendr app.
22 lines (16 loc) • 584 B
JavaScript
/**
* Extend `each` to pass through important context.
*/
var _ = require('underscore'),
getOptionsFromContext = require('../../lib/getOptions'),
oldEach;
module.exports = function(Handlebars) {
oldEach = oldEach || Handlebars.helpers.each;
return function (context, options) {
options.data = Handlebars.createFrame(options.data || {});
// Make sure `this._app`, `this._view`, etc are available.
_.extend(options.data, getOptionsFromContext(this));
// Call the original helper with new context.
return oldEach.call(this, context, options);
}
};