Controller.js 486 B

1234567891011121314151617181920212223242526
  1. /**
  2. * Created by benzhan on 15/8/13.
  3. */
  4. var prototype = Controller.prototype;
  5. function Controller() {
  6. }
  7. var data = {};
  8. prototype.assign = function(key, value) {
  9. if (typeof key == 'object') {
  10. for (var k in key) {
  11. data[k] = key[k];
  12. }
  13. } else {
  14. data[key] = value;
  15. }
  16. };
  17. prototype.display = function(tpl) {
  18. tpl = tpl || CONTROLLER_NAME + '/' + ACTION_NAME;
  19. _res.render(tpl, data);
  20. }
  21. module.exports = Controller;