Skip to content

Commit

Permalink
Publish a Node.js require() handler for handlebars files
Browse files Browse the repository at this point in the history
  • Loading branch information
jjclark1982 committed May 14, 2013
1 parent 4cf0410 commit 531be77
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/handlebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,17 @@ Handlebars.create = create;

module.exports = Handlebars; // instantiate an instance

// Publish a Node.js require() handler for handlebars files
if ((typeof(require) !== "undefined") && require.extensions) {
var extension = function(module, filename) {
var fs = require("fs");
var templateString = fs.readFileSync(filename, 'utf8');
module.exports = Handlebars.compile(templateString);
};
require.extensions[".handlebars"] = extension;
require.extensions[".hbs"] = extension;
}

// BEGIN(BROWSER)

// END(BROWSER)
Expand Down

0 comments on commit 531be77

Please sign in to comment.