Improve readability
This commit is contained in:
parent
f6520b7dc7
commit
69e72af622
@ -61,8 +61,7 @@ def fragment_cache_key(key)
|
||||
end
|
||||
|
||||
def fragment_for(block, name = {}, options = nil) #:nodoc:
|
||||
unless perform_caching then block.call; return end
|
||||
|
||||
if perform_caching
|
||||
buffer = yield
|
||||
|
||||
if cache = read_fragment(name, options)
|
||||
@ -72,6 +71,9 @@ def fragment_for(block, name = {}, options = nil) #:nodoc:
|
||||
block.call
|
||||
write_fragment(name, buffer[pos..-1], options)
|
||||
end
|
||||
else
|
||||
block.call
|
||||
end
|
||||
end
|
||||
|
||||
# Writes <tt>content</tt> to the location signified by <tt>key</tt> (see <tt>expire_fragment</tt> for acceptable formats)
|
||||
|
@ -53,7 +53,9 @@ def compile(template)
|
||||
end
|
||||
|
||||
def cache_fragment(block, name = {}, options = nil) #:nodoc:
|
||||
@view.fragment_for(block, name, options) { @view.response.template.output_buffer ||= '' }
|
||||
@view.fragment_for(block, name, options) do
|
||||
@view.response.template.output_buffer
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user