allow user to prevent layout render

This commit is contained in:
Blake Mizerany 2008-03-15 17:20:37 -07:00
parent 5f3eac0344
commit 898b36eab4
2 changed files with 15 additions and 0 deletions

View File

@ -363,6 +363,7 @@ module Sinatra
end
def determine_layout(renderer, template, options)
return if options[:layout] == false
layout_from_options = options[:layout] || :layout
layout = layouts[layout_from_options]
layout ||= resolve_template(renderer, layout_from_options, options, false)

View File

@ -137,6 +137,20 @@ context "Haml" do
end
specify "can render with no layout" do
layout do
"X\n= yield\nX"
end
get '/' do
haml 'blake', :layout => false
end
get_it '/'
body.should.equal "blake\n"
end
specify "raises error if template not found" do
get '/' do
haml :not_found