Skip to content

Instantly share code, notes, and snippets.

@pward123
Created March 16, 2014 15:50
Show Gist options
  • Save pward123/9585236 to your computer and use it in GitHub Desktop.
Save pward123/9585236 to your computer and use it in GitHub Desktop.
Meteor pre-blaze "include" helper
// Taken from:
// https://github.com/wycats/handlebars.js/pull/385
// http://jsfiddle.net/QV9em/4/
//
// {{#each items}}
// {{#include section=..}}
// {{> sectionItem}}
// {{/include}}
// {{/each}}
Handlebars.registerHelper('include', function(options) {
var name = options.hash.template,
context = {},
mergeContext = function(obj) {
for(var k in obj)context[k]=obj[k];
};
mergeContext(this);
mergeContext(_.omit(options.hash, 'template'));
return options.fn(context);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment