visionmedia / express-resource

Resourceful routing for Express
1.41k stars 140 forks source link

bodyClasses dynamic helper #11

Closed ravinggenius closed 13 years ago

ravinggenius commented 13 years ago

It would be nice if generating a resource, like below, would create a dynamic helper for the view. This would be super useful for styling specific pages.

app.resource('forums', require('./forum'));
exports.index = function(req, res){
  res.send('forum index');
};
// bodyClasses() //=> 'forums index'

exports.new = function(req, res){
  res.send('new forum');
};
// bodyClasses() //=> 'forums new'

exports.create = function(req, res){
  res.send('create forum');
};
// bodyClasses() //=> 'forums create'

exports.show = function(req, res){
  res.send('show forum ' + req.params.id);
};
// bodyClasses() //=> 'forums show'

exports.edit = function(req, res){
  res.send('edit forum ' + req.params.id);
};
// bodyClasses() //=> 'forums edit'

exports.update = function(req, res){
  res.send('update forum ' + req.params.id);
};
// bodyClasses() //=> 'forums update'

exports.destroy = function(req, res){
  res.send('destroy forum ' + req.params.id);
};
// bodyClasses() //=> 'forums destroy'
ravinggenius commented 13 years ago

Any word on this?

tj commented 13 years ago

i dont want to add body class support directly, that's too ad hoc but this will do the trick

tj commented 13 years ago

https://github.com/visionmedia/express/commit/91997e9c53db057667981d5f5ece6eb15a8d1059