mirror of
https://github.com/sinatra/sinatra
synced 2023-03-27 23:18:01 -04:00
allow user to prevent layout render
This commit is contained in:
parent
5f3eac0344
commit
898b36eab4
2 changed files with 15 additions and 0 deletions
|
@ -363,6 +363,7 @@ module Sinatra
|
||||||
end
|
end
|
||||||
|
|
||||||
def determine_layout(renderer, template, options)
|
def determine_layout(renderer, template, options)
|
||||||
|
return if options[:layout] == false
|
||||||
layout_from_options = options[:layout] || :layout
|
layout_from_options = options[:layout] || :layout
|
||||||
layout = layouts[layout_from_options]
|
layout = layouts[layout_from_options]
|
||||||
layout ||= resolve_template(renderer, layout_from_options, options, false)
|
layout ||= resolve_template(renderer, layout_from_options, options, false)
|
||||||
|
|
|
@ -137,6 +137,20 @@ context "Haml" do
|
||||||
|
|
||||||
end
|
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
|
specify "raises error if template not found" do
|
||||||
get '/' do
|
get '/' do
|
||||||
haml :not_found
|
haml :not_found
|
||||||
|
|
Loading…
Reference in a new issue