Skip to content

Instantly share code, notes, and snippets.

@felixrieseberg
Created October 1, 2014 16:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save felixrieseberg/a120ce8c48be3904e971 to your computer and use it in GitHub Desktop.
Save felixrieseberg/a120ce8c48be3904e971 to your computer and use it in GitHub Desktop.
Turning a template into a module
// Requires export of Express app object:
// var app = module.exports = express();
var app = require('app');
var templateToModule = function(template) {
this.template = template;
}
templateToModule.prototype.render = function(callback) {
app.render(this.template, function(error, html) {
if (!error) {
callback(html);
}
};
};
module.exports = templateToModule;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment