Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed problem referencing 'global/nav' from layout.

Applied solution from @timshadel in mauricemach/zappa#103
  • Loading branch information...
commit ae8403e78a37eb71759d1d8fa79c0a7bee842427 1 parent 6804afc
@shimaore shimaore authored
Showing with 21 additions and 2 deletions.
  1. +21 −2 src/zappa.coffee
View
23 src/zappa.coffee
@@ -74,7 +74,12 @@ express.View.prototype.__defineGetter__ 'exists', ->
fs.statSync(p)
return true
catch err
- return false
+ p = @path
+ try
+ fs.statSync(p)
+ return true
+ catch err
+ return false
express.View.prototype.__defineGetter__ 'contents', ->
# Path given by zappa: /path/to/appid/foo.bar.
@@ -90,7 +95,11 @@ express.View.prototype.__defineGetter__ 'contents', ->
# Try /path/to/foo.bar in filesystem (normal express behaviour).
p = @path.replace id + '/', ''
- fs.readFileSync p, 'utf8'
+ try
+ fs.readFileSync p, 'utf8'
+ catch err
+ p = @path
+ fs.readFileSync p, 'utf8'
# Takes in a function and builds express/socket.io apps based on the rules contained in it.
zappa.app = (func) ->
@@ -281,6 +290,16 @@ zappa.app = (func) ->
if app.settings['databag']
args[1].params = data
+ # Don't change layout: false
+ unless args[1].layout is false
+ # Use the default layout if one isn't given, or layout: true
+ if args[1].layout is true or not args[1].layout?
+ args[1].layout = 'layout'
+
+ # Don't add id if it's there already
+ if args[1].layout.split('/')[0] is not context.id
+ args[1].layout = context.id + '/' + args[1].layout
+
if args[1].postrender?
# Apply postrender before sending response.
res.render args[0], args[1], (err, str) ->
Please sign in to comment.
Something went wrong with that request. Please try again.