From 3ccea931fac2872ffb26014592c036b5d137655f Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sun, 24 Jul 2005 15:27:47 +0000 Subject: Simplify content_for implementation git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1914 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/lib/action_view/helpers/capture_helper.rb | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) (limited to 'actionpack/lib') diff --git a/actionpack/lib/action_view/helpers/capture_helper.rb b/actionpack/lib/action_view/helpers/capture_helper.rb index d430121b04..5c1f32a96c 100644 --- a/actionpack/lib/action_view/helpers/capture_helper.rb +++ b/actionpack/lib/action_view/helpers/capture_helper.rb @@ -81,17 +81,9 @@ module ActionView # # NOTE: Beware that content_for is ignored in caches. So you shouldn't use it # for elements that are going to be fragment cached. - def content_for(name, &block) - base = instance_variable_get(instance_var_name(name)) || "" - data = capture(&block) - instance_variable_set(instance_var_name(name), base + data) - data + def content_for(name, &block) + eval "@content_for_#{name} = (@content_for_#{name} || '') + capture(&block)" end - - private - def instance_var_name(name) #:nodoc# - "@content_for_#{name}" - end end end end -- cgit v1.2.3