Permalink
Browse files

Do not render unknown file type

  • Loading branch information...
1 parent 1275da8 commit 8b23f8bcde70a430416fa0ed15bfa31a59786a3c @eldargab committed Jun 9, 2012
Showing with 6 additions and 9 deletions.
  1. +6 −9 lib/render.js
View
15 lib/render.js
@@ -6,22 +6,19 @@ var mime = require('mime')
module.exports = function (Engine) {
return function render (file, req, res, next) {
var engine = Engine(extname(file))
- if (engine && engine.renderFile) {
+ if (!engine) return next()
+ if (engine.renderFile) {
engine.renderFile(file, function (error, out) {
if (error) return onerror(error, next)
send(out, engine.contentType)
})
} else {
fs.readFile(file, 'utf8', function (error, string) {
if (error) return onerror(error, next)
- if (engine) {
- engine.render(string, function (error, out) {
- if (error) return next(error)
- send(out, engine.contentType)
- })
- } else {
- send(string, mime.lookup(file))
- }
+ engine.render(string, function (error, out) {
+ if (error) return next(error)
+ send(out, engine.contentType)
+ })
})
}

0 comments on commit 8b23f8b

Please sign in to comment.