Use the default layout when calling :layout => true

This helps to write things like:

  haml :template, :layout => !request.xhr?
This commit is contained in:
Damian Janowski 2009-01-08 15:01:36 -02:00 committed by Ryan Tomayko
parent 67906d391d
commit d4f9d0043c
2 changed files with 9 additions and 0 deletions

View File

@ -210,6 +210,7 @@ module Sinatra
def lookup_layout(engine, options)
return if options[:layout] == false
options.delete(:layout) if options[:layout] == true
template = options[:layout] || :layout
data = lookup_template(engine, template, options)
[template, data]

View File

@ -52,6 +52,14 @@ describe 'Templating' do
end
end
it 'uses the default layout template if not really overriden' do
with_default_layout do
render_app { render :test, :hello, :layout => true }
should.be.ok
body.should.equal "Layout!\nHello World!\n"
end
end
it 'uses the layout template specified' do
render_app { render :test, :hello, :layout => :layout2 }
should.be.ok