Use the default layout when calling :layout => true
This helps to write things like: haml :template, :layout => !request.xhr?
This commit is contained in:
parent
67906d391d
commit
d4f9d0043c
|
@ -210,6 +210,7 @@ module Sinatra
|
||||||
|
|
||||||
def lookup_layout(engine, options)
|
def lookup_layout(engine, options)
|
||||||
return if options[:layout] == false
|
return if options[:layout] == false
|
||||||
|
options.delete(:layout) if options[:layout] == true
|
||||||
template = options[:layout] || :layout
|
template = options[:layout] || :layout
|
||||||
data = lookup_template(engine, template, options)
|
data = lookup_template(engine, template, options)
|
||||||
[template, data]
|
[template, data]
|
||||||
|
|
|
@ -52,6 +52,14 @@ describe 'Templating' do
|
||||||
end
|
end
|
||||||
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
|
it 'uses the layout template specified' do
|
||||||
render_app { render :test, :hello, :layout => :layout2 }
|
render_app { render :test, :hello, :layout => :layout2 }
|
||||||
should.be.ok
|
should.be.ok
|
||||||
|
|
Loading…
Reference in New Issue