mirror of
https://github.com/sinatra/sinatra
synced 2023-03-27 23:18:01 -04:00
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
2 changed files with 9 additions and 0 deletions
|
@ -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]
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue