Remove some internal dead code that supported content_for
This commit is contained in:
parent
26ec1be24a
commit
fe9d2ad6e8
@ -32,7 +32,7 @@ module CaptureHelper
|
||||
#
|
||||
def capture(*args, &block)
|
||||
if @output_buffer
|
||||
with_temporary_output_buffer { yield *args }
|
||||
with_output_buffer { block.call(*args) }
|
||||
else
|
||||
block.call(*args)
|
||||
end
|
||||
@ -115,27 +115,17 @@ def capture(*args, &block)
|
||||
# <tt><%= yield :footer %></tt>.
|
||||
def content_for(name, content = nil, &block)
|
||||
ivar = "@content_for_#{name}"
|
||||
instance_variable_set("@content_for_#{name}", "#{instance_variable_get(ivar)}#{block_given? ? capture(&block) : content}")
|
||||
content = capture(&block) if block_given?
|
||||
instance_variable_set(ivar, "#{instance_variable_get(ivar)}#{content}")
|
||||
end
|
||||
|
||||
private
|
||||
def with_temporary_output_buffer
|
||||
@output_buffer, old_buffer = '', @output_buffer
|
||||
def with_output_buffer(buf = '')
|
||||
@output_buffer, old_buffer = buf, @output_buffer
|
||||
yield
|
||||
@output_buffer
|
||||
ensure
|
||||
@output_buffer = old_buffer
|
||||
end
|
||||
|
||||
def erb_content_for(name, &block)
|
||||
ivar = "@content_for_#{name}"
|
||||
instance_variable_set(ivar, "#{instance_variable_get(ivar)}#{capture(&block)}")
|
||||
end
|
||||
|
||||
def block_content_for(name)
|
||||
ivar = "@content_for_#{name}"
|
||||
instance_variable_set(ivar, "#{instance_variable_get(ivar)}#{yield}")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -11,19 +11,11 @@ def content_for
|
||||
def content_for_with_parameter
|
||||
render :layout => "talk_from_action"
|
||||
end
|
||||
|
||||
|
||||
def content_for_concatenated
|
||||
render :layout => "talk_from_action"
|
||||
end
|
||||
|
||||
def erb_content_for
|
||||
render :layout => "talk_from_action"
|
||||
end
|
||||
|
||||
def block_content_for
|
||||
render :layout => "talk_from_action"
|
||||
end
|
||||
|
||||
def non_erb_block_content_for
|
||||
render :layout => "talk_from_action"
|
||||
end
|
||||
@ -62,21 +54,11 @@ def test_should_concatentate_content_for
|
||||
assert_equal expected_content_for_output, @response.body
|
||||
end
|
||||
|
||||
def test_erb_content_for
|
||||
get :erb_content_for
|
||||
assert_equal expected_content_for_output, @response.body
|
||||
end
|
||||
|
||||
def test_should_set_content_for_with_parameter
|
||||
get :content_for_with_parameter
|
||||
assert_equal expected_content_for_output, @response.body
|
||||
end
|
||||
|
||||
def test_block_content_for
|
||||
get :block_content_for
|
||||
assert_equal expected_content_for_output, @response.body
|
||||
end
|
||||
|
||||
def test_non_erb_block_content_for
|
||||
get :non_erb_block_content_for
|
||||
assert_equal expected_content_for_output, @response.body
|
||||
|
@ -1,2 +0,0 @@
|
||||
<% block_content_for :title do 'Putting stuff in the title!' end %>
|
||||
Great stuff!
|
@ -1,2 +0,0 @@
|
||||
<% erb_content_for :title do %>Putting stuff in the title!<% end %>
|
||||
Great stuff!
|
Loading…
Reference in New Issue
Block a user