Permalink
Browse files

Don't leave @default_layout set to false if rendering a template fails.

  • Loading branch information...
1 parent 4c6b1fa commit 313def15eeced2678a7bbfdcd722fda52473143d @nbaum nbaum 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 313def1

Please sign in to comment.