Skip to content

Instantly share code, notes, and snippets.

@pacovell
Created July 12, 2011 16:06
Show Gist options
  • Save pacovell/1078292 to your computer and use it in GitHub Desktop.
Save pacovell/1078292 to your computer and use it in GitHub Desktop.
Defines dynamicViewHelpers, included as per the server.js configuration also attached
module.exports = function setup() {
var fns = {},
methodName;
function makeHelperFunction(fn) {
return function(req, res) {
return fn;
};
}
for(methodName in this.path) {
if (this.path.hasOwnProperty(methodName) && 'function' === typeof this.path[methodName]) {
fns[methodName] = makeHelperFunction(this.path[methodName]);
}
}
return fns;
};
// TEMPORARY -- ideally will be included in the express-resource somewhere
app.resource.dynamicHelpers = require(process.cwd() + '/app/helpers/resourceful_urls');
// Add dynamic helpers
app.dynamicHelpers(app.resource.dynamicHelpers());
login= users_path()
a(href=forum_path(forum))= forum.name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment