diff --git a/lib/sinatra/base.rb b/lib/sinatra/base.rb index 2209db97da..0f4cacc634 100644 --- a/lib/sinatra/base.rb +++ b/lib/sinatra/base.rb @@ -467,7 +467,7 @@ def render(engine, data, options={}, locals={}, &block) # compile and render template layout_was = @default_layout - @default_layout = false if layout + @default_layout = false template = compile_template(engine, data, options, views) output = template.render(self, locals, &block) @default_layout = layout_was diff --git a/test/templates_test.rb b/test/templates_test.rb index 48f0ec65dc..f5729f36eb 100644 --- a/test/templates_test.rb +++ b/test/templates_test.rb @@ -101,6 +101,15 @@ def with_default_layout assert_equal "

String Layout!

\n

Hello From String

", body end + it 'is possible to use partials in layouts' do + render_app do + settings.layout { "<%= erb 'foo' %><%= yield %>" } + erb 'bar' + end + assert ok? + assert_equal "foobar", body + end + it 'loads templates from source file' do mock_app { enable :inline_templates } assert_equal "this is foo\n\n", @app.templates[:foo][0]