Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Improve readability

  • Loading branch information...
commit 69e72af62261dd8971890711b51c6eef2c68bc71 1 parent f6520b7
Jeremy Kemper jeremy authored
18 actionpack/lib/action_controller/caching/fragments.rb
View
@@ -61,16 +61,18 @@ def fragment_cache_key(key)
end
def fragment_for(block, name = {}, options = nil) #:nodoc:
- unless perform_caching then block.call; return end
-
- buffer = yield
-
- if cache = read_fragment(name, options)
- buffer.concat(cache)
+ if perform_caching
+ buffer = yield
+
+ if cache = read_fragment(name, options)
+ buffer.concat(cache)
+ else
+ pos = buffer.length
+ block.call
+ write_fragment(name, buffer[pos..-1], options)
+ end
else
- pos = buffer.length
block.call
- write_fragment(name, buffer[pos..-1], options)
end
end
4 actionpack/lib/action_view/template_handlers/erb.rb
View
@@ -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

1 comment on commit 69e72af

Josh Nichols

In the old revision, it does a block.call unless perform_caching (line 64), so wouldn’t that need to be somewhere in the new revision?

Maybe in an else clause for the ‘if perform_caching’?

Please sign in to comment.
Something went wrong with that request. Please try again.