Skip to content

Instantly share code, notes, and snippets.

@raine
Created October 25, 2011 16:14
Show Gist options
  • Select an option

  • Save raine/1313302 to your computer and use it in GitHub Desktop.

Select an option

Save raine/1313302 to your computer and use it in GitHub Desktop.
function require(name) {
var exports = {};
window.modules[name](exports);
return exports;
}
res.render('modules.ejs', {
locals: {
files: {
helpers: fs.readFileSync('helpers.js', 'utf8')
}
},
layout: false
});
window.modules = {};
<% for (var file in locals.files) { %>
window.modules['<%- file %>'] = function(exports) {
<%- locals.files[file] %>
<% } %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment