mirror of
https://github.com/sinatra/sinatra
synced 2023-03-27 23:18:01 -04:00
Make neste layout usage independed of the outer template's :layout value. Allows using partials in layouts.
This commit is contained in:
parent
796d62a487
commit
5d15ddf3a1
2 changed files with 10 additions and 1 deletions
|
@ -471,7 +471,7 @@ module Sinatra
|
|||
|
||||
# compile and render template
|
||||
layout_was = @default_layout
|
||||
@default_layout = false if layout
|
||||
@default_layout = false
|
||||
template = compile_template(engine, data, options, views)
|
||||
output = template.render(self, locals, &block)
|
||||
@default_layout = layout_was
|
||||
|
|
|
@ -101,6 +101,15 @@ class TemplatesTest < Test::Unit::TestCase
|
|||
assert_equal "<h1>String Layout!</h1>\n<content><h1>Hello From String</h1></content>", body
|
||||
end
|
||||
|
||||
it 'is possible to use partials in layouts' do
|
||||
render_app do
|
||||
settings.layout { "<%= erb 'foo' %><%= yield %>" }
|
||||
erb 'bar'
|
||||
end
|
||||
assert ok?
|
||||
assert_equal "foobar", body
|
||||
end
|
||||
|
||||
it 'loads templates from source file' do
|
||||
mock_app { enable :inline_templates }
|
||||
assert_equal "this is foo\n\n", @app.templates[:foo][0]
|
||||
|
|
Loading…
Reference in a new issue