Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Make nested layout usage independed of the outer template's :layout v…

…alue. Allows using partials in layouts.
  • Loading branch information...
commit f2d1e21f690d3e5f2a13633b5b8ebde833927da4 1 parent 9065bb4
@rkh rkh authored
Showing with 10 additions and 1 deletion.
  1. +1 −1  lib/sinatra/base.rb
  2. +9 −0 test/templates_test.rb
View
2  lib/sinatra/base.rb
@@ -467,7 +467,7 @@ def render(engine, data, options={}, locals={}, &block)
# 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
View
9 test/templates_test.rb
@@ -101,6 +101,15 @@ def with_default_layout
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]
Please sign in to comment.
Something went wrong with that request. Please try again.