Skip to content

Commit

Permalink
Don't leave @default_layout set to false if rendering a template fails.
Browse files Browse the repository at this point in the history
  • Loading branch information
nbaum authored and rkh committed Oct 14, 2011
1 parent a25bff1 commit 4384dda
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions lib/sinatra/base.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -568,11 +568,14 @@ def render(engine, data, options={}, locals={}, &block)
scope = options.delete(:scope) || self scope = options.delete(:scope) || self


# compile and render template # compile and render template
layout_was = @default_layout begin
@default_layout = false layout_was = @default_layout
template = compile_template(engine, data, options, views) @default_layout = false
output = template.render(scope, locals, &block) template = compile_template(engine, data, options, views)
@default_layout = layout_was output = template.render(scope, locals, &block)
ensure
@default_layout = layout_was
end


# render layout # render layout
if layout if layout
Expand Down

0 comments on commit 4384dda

Please sign in to comment.