1
0
Fork 0
mirror of https://github.com/sinatra/sinatra synced 2023-03-27 23:18:01 -04:00

Fix issue setting content_for value with method param

This commit is contained in:
Jordan Owens 2018-12-01 23:50:51 -05:00
parent 9fef844f06
commit 4396f1e6a8
6 changed files with 10 additions and 2 deletions

View file

@ -97,8 +97,7 @@ module Sinatra
result = block[*args] result = block[*args]
elsif current_engine == :erb || current_engine == :slim elsif current_engine == :erb || current_engine == :slim
@_out_buf, _buf_was = '', @_out_buf @_out_buf, _buf_was = '', @_out_buf
block[*args] result = block.call(*args)
result = eval('@_out_buf', block.binding)
@_out_buf = _buf_was @_out_buf = _buf_was
else else
buffer = eval '_buf if defined?(_buf)', block.binding buffer = eval '_buf if defined?(_buf)', block.binding

View file

@ -0,0 +1 @@
<% content_for :foo, 'foo' %>

View file

@ -0,0 +1 @@
<% content_for :foo, 'foo' %>

View file

@ -0,0 +1 @@
- content_for :foo, 'foo'

View file

@ -0,0 +1 @@
- content_for :foo, 'foo'

View file

@ -210,6 +210,11 @@ describe Sinatra::ContentFor do
expect(body).to eq("bar") expect(body).to eq("bar")
end 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 it 'renders blocks declared with the same key you use when rendering' do
expect(get('/same_key')).to be_ok expect(get('/same_key')).to be_ok
expect(body).to eq("foo") expect(body).to eq("foo")