Skip to content
Browse files

Fixed ways views are called so that it works in production

  • Loading branch information...
1 parent 6a0c95e commit cb3c58dad726e0e987499f85874353e09ae012af @ajorkowski committed Mar 12, 2012
Showing with 5 additions and 12 deletions.
  1. +2 −5 lib/controllers.js
  2. +1 −1 package.json
  3. +2 −6 src/controllers.coffee
View
7 lib/controllers.js
@@ -287,7 +287,6 @@
result = null;
secondResult = null;
reset = function() {
- resp.app.set('views', root);
if (hasHints) return resp.app.enable('hints');
};
finalPass = function(err, err2, str) {
@@ -305,8 +304,7 @@
};
secondRender = function(err, str) {
if (err != null) {
- resp.app.set('views', root + '/' + self.options.sharedFolder);
- return secondResult = original.call(resp, view, opts, (function(err2, str2) {
+ return secondResult = original.call(resp, self.options.sharedFolder + '/' + view, opts, (function(err2, str2) {
return finalPass(err2, err, str2);
}), parent, sub);
} else {
@@ -318,8 +316,7 @@
}
}
};
- resp.app.set('views', root + '/' + req.controller);
- result = original.call(resp, view, opts, secondRender, parent, sub);
+ result = original.call(resp, req.controller + '/' + view, opts, secondRender, parent, sub);
if (secondResult != null) result = secondResult;
reset();
return result;
View
2 package.json
@@ -2,7 +2,7 @@
"author": "Felix Jorkowski (http://jorkowski.com)",
"name": "controllers",
"description": "A simple mvc framework and route extender for Express",
- "version": "0.0.1",
+ "version": "0.0.2",
"homepage": "https://github.com/ajorkowski/controllers",
"repository": {
"type": "git",
View
8 src/controllers.coffee
@@ -278,8 +278,6 @@ class Controllers
secondResult = null
reset = ->
- resp.app.set 'views', root
-
if hasHints
resp.app.enable 'hints'
@@ -300,8 +298,7 @@ class Controllers
secondRender = (err, str) ->
if err?
# If the first render failed failed try getting view from 'shared'
- resp.app.set 'views', root + '/' + self.options.sharedFolder
- secondResult = original.call resp, view, opts, ((err2, str2) -> finalPass(err2, err, str2)), parent, sub
+ secondResult = original.call resp, self.options.sharedFolder + '/' + view, opts, ((err2, str2) -> finalPass(err2, err, str2)), parent, sub
else
reset()
@@ -310,8 +307,7 @@ class Controllers
else
resp.send str
- resp.app.set 'views', root + '/' + req.controller
- result = original.call resp, view, opts, secondRender, parent, sub
+ result = original.call resp, req.controller + '/' + view, opts, secondRender, parent, sub
if secondResult?
result = secondResult

0 comments on commit cb3c58d

Please sign in to comment.
Something went wrong with that request. Please try again.