Skip to content

Commit

Permalink
Fix issue setting content_for value with method param
Browse files Browse the repository at this point in the history
  • Loading branch information
jkowens committed Dec 2, 2018
1 parent 37f18fa commit 338e877
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 2 deletions.
3 changes: 1 addition & 2 deletions sinatra-contrib/lib/sinatra/capture.rb
Expand Up @@ -96,8 +96,7 @@ def capture(*args, &block)
result = block[*args]
elsif current_engine == :erb || current_engine == :slim
@_out_buf, _buf_was = '', @_out_buf
block[*args]
result = eval('@_out_buf', block.binding)
result = block.call(*args)
@_out_buf = _buf_was
else
buffer = eval '_buf if defined?(_buf)', block.binding
Expand Down
1 change: 1 addition & 0 deletions sinatra-contrib/spec/content_for/parameter_value.erb
@@ -0,0 +1 @@
<% content_for :foo, 'foo' %>
1 change: 1 addition & 0 deletions sinatra-contrib/spec/content_for/parameter_value.erubis
@@ -0,0 +1 @@
<% content_for :foo, 'foo' %>
1 change: 1 addition & 0 deletions sinatra-contrib/spec/content_for/parameter_value.haml
@@ -0,0 +1 @@
- content_for :foo, 'foo'
1 change: 1 addition & 0 deletions sinatra-contrib/spec/content_for/parameter_value.slim
@@ -0,0 +1 @@
- content_for :foo, 'foo'
5 changes: 5 additions & 0 deletions sinatra-contrib/spec/content_for_spec.rb
Expand Up @@ -210,6 +210,11 @@ def body
expect(body).to eq("bar")
end

it 'renders content set as parameter' do
expect(get('/parameter_value')).to be_ok
expect(body).to eq("foo")
end

it 'renders blocks declared with the same key you use when rendering' do
expect(get('/same_key')).to be_ok
expect(body).to eq("foo")
Expand Down

0 comments on commit 338e877

Please sign in to comment.