Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Use the default layout when calling :layout => true

This helps to write things like:

  haml :template, :layout => !request.xhr?
  • Loading branch information...
commit b26df9ae95cacb6fb84842bd8ee5895809330ca2 1 parent 67906d3
Damian Janowski djanowski authored bmizerany committed
Showing with 9 additions and 0 deletions.
  1. +1 −0  lib/sinatra/base.rb
  2. +8 −0 test/templates_test.rb
1  lib/sinatra/base.rb
View
@@ -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]
8 test/templates_test.rb
View
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.