diff --git a/lib/sinatra/base.rb b/lib/sinatra/base.rb index 09f2c9d1..462a8a80 100644 --- a/lib/sinatra/base.rb +++ b/lib/sinatra/base.rb @@ -471,7 +471,7 @@ module Sinatra # 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 48f0ec65..f5729f36 100644 --- a/test/templates_test.rb +++ b/test/templates_test.rb @@ -101,6 +101,15 @@ class TemplatesTest < Test::Unit::TestCase 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]