Permalink
Browse files

Merge pull request #388 from nbaum/master

Don't leave @default_layout set to false if rendering a template fails
  • Loading branch information...
2 parents 4c6b1fa + 313def1 commit 2a9e7b60df717b281d6039f8d515141bcd2c5354 @rkh rkh committed Oct 14, 2011
Showing with 8 additions and 5 deletions.
  1. +8 −5 lib/sinatra/base.rb
View
@@ -619,11 +619,14 @@ def render(engine, data, options={}, locals={}, &block)
scope = options.delete(:scope) || self
# compile and render template
- layout_was = @default_layout
- @default_layout = false
- template = compile_template(engine, data, options, views)
- output = template.render(scope, locals, &block)
- @default_layout = layout_was
+ begin
+ layout_was = @default_layout
+ @default_layout = false
+ template = compile_template(engine, data, options, views)
+ output = template.render(scope, locals, &block)
+ ensure
+ @default_layout = layout_was
+ end
# render layout
if layout

0 comments on commit 2a9e7b6

Please sign in to comment.