mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Simplify content_for implementation
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1914 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user