Skip to content

Commit

Permalink
Made defs available to postrenders' scope.
Browse files Browse the repository at this point in the history
  • Loading branch information
mauricemach committed Dec 26, 2010
1 parent 2f11ca1 commit 79bca6f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/zappa.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -219,14 +219,15 @@ class RequestHandler
@locals.redirect = @redirect
@locals.send = @send
@locals.puts = puts

for k, v of @defs
@locals[k] = v

for k, v of @helpers
@locals[k] = ->
v(@context, @, arguments)

@locals.defs = @defs
@locals.postrenders = @postrenders
@locals.views = @views
@locals.layouts = @layouts
Expand Down Expand Up @@ -280,7 +281,7 @@ class RequestHandler
postrender = @postrenders[options.apply]
body = jquery('body')
body.empty().html(result)
postrender opts.context, $: jquery
postrender opts.context, jquery.extend(@defs, {$: jquery})
result = body.html()

if options.layout
Expand Down Expand Up @@ -315,6 +316,7 @@ class MessageHandler
@locals[k] = ->
v(@context, @, arguments)

@locals.defs = @app.defs
@locals.postrenders = @app.postrenders
@locals.views = @app.views
@locals.layouts = @app.layouts
Expand Down Expand Up @@ -358,7 +360,7 @@ class MessageHandler
postrender = @postrenders[options.apply]
body = jquery('body')
body.empty().html(result)
postrender opts.context, $: jquery
postrender opts.context, jquery.extend(@defs, {$: jquery})
result = body.html()

if options.layout
Expand Down

0 comments on commit 79bca6f

Please sign in to comment.