Skip to content

Instantly share code, notes, and snippets.

@jonschlinkert
Created November 5, 2015 16:55
Show Gist options
  • Save jonschlinkert/2df0cfd4ae170ac79e10 to your computer and use it in GitHub Desktop.
Save jonschlinkert/2df0cfd4ae170ac79e10 to your computer and use it in GitHub Desktop.
This handlebars helper is for grunt-assemble 0.4.x. Newer versions of assemble make this easier and probably not needed at all.
var extend = require('extend-shallow');
var fs = require('fs');
module.exports.register = function (handlebars, options) {
// you should be able to set `cwd` on assemble options in
// your grunt config
var opts = extend({cwd: ''}, options);
handlebars.registerHelper('include', function (filename) {
// to see what's on the context, do the following:
console.log(this);
var fp = path.join(opts.cwd, filename);
return fs.readFileSync(fp, 'utf8');
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment