Skip to content

Commit

Permalink
Use the default layout when calling :layout => true
Browse files Browse the repository at this point in the history
This helps to write things like:

  haml :template, :layout => !request.xhr?
  • Loading branch information
djanowski authored and bmizerany committed Jan 10, 2009
1 parent 67906d3 commit b26df9a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/sinatra/base.rb
Expand Up @@ -210,6 +210,7 @@ def lookup_template(engine, template, options={})

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]
Expand Down
8 changes: 8 additions & 0 deletions test/templates_test.rb
Expand Up @@ -52,6 +52,14 @@ def with_default_layout
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
Expand Down

0 comments on commit b26df9a

Please sign in to comment.