Skip to content

Commit

Permalink
Request#render() only calls cache.get() once
Browse files Browse the repository at this point in the history
  • Loading branch information
tj committed Mar 18, 2010
1 parent fc1e69e commit 8dcee4d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/express/plugins/view.js
Expand Up @@ -61,7 +61,8 @@ exports.View = Plugin.extend({
*/

render: function(view, options) {
var self = this,
var cache,
self = this,
options = options || {},
path = set('views') + '/' + view,
type = path.split('.').slice(-2)[0],
Expand All @@ -81,8 +82,8 @@ exports.View = Plugin.extend({
else
self.halt(200, content)
}
if (set('cache view contents') && self.cache.get('view:' + path))
render(self.cache.get('view:' + path))
if (set('cache view contents') && (cache = self.cache.get('view:' + path)))
render(cache)
else
fs.readFile(path, function(err, content){
if (err) throw err
Expand Down

0 comments on commit 8dcee4d

Please sign in to comment.