diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2010-06-07 20:54:53 -0400 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2010-06-08 14:47:02 -0400 |
commit | 585f8f27b190637fd0bad67d7d611eed5ae262e7 (patch) | |
tree | f072f100c847d275c1e079eb7fdeb8ff4ed1498b /actionpack/lib/action_view | |
parent | eb69721c9bf2bd0f8957a231ecc91080b0645b84 (diff) | |
download | rails-585f8f27b190637fd0bad67d7d611eed5ae262e7.tar.gz rails-585f8f27b190637fd0bad67d7d611eed5ae262e7.tar.bz2 rails-585f8f27b190637fd0bad67d7d611eed5ae262e7.zip |
Fixed double output from cache in no caching mode
Diffstat (limited to 'actionpack/lib/action_view')
-rw-r--r-- | actionpack/lib/action_view/helpers/cache_helper.rb | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/actionpack/lib/action_view/helpers/cache_helper.rb b/actionpack/lib/action_view/helpers/cache_helper.rb index a904af56bb..8251ed18f4 100644 --- a/actionpack/lib/action_view/helpers/cache_helper.rb +++ b/actionpack/lib/action_view/helpers/cache_helper.rb @@ -32,27 +32,27 @@ module ActionView # <i>Topics listed alphabetically</i> # <% end %> def cache(name = {}, options = nil, &block) - safe_concat fragment_for(name, options, &block) + if controller.perform_caching + safe_concat(fragment_for(name, options, &block)) + else + yield + end + nil end private # TODO: Create an object that has caching read/write on it def fragment_for(name = {}, options = nil, &block) #:nodoc: - if controller.perform_caching - if controller.fragment_exist?(name, options) - controller.read_fragment(name, options) - else - # VIEW TODO: Make #capture usable outside of ERB - # This dance is needed because Builder can't use capture - pos = output_buffer.length - yield - fragment = output_buffer.slice!(pos..-1) - controller.write_fragment(name, fragment, options) - end + if controller.fragment_exist?(name, options) + controller.read_fragment(name, options) else - ret = yield - ActiveSupport::SafeBuffer.new(ret) if ret.is_a?(String) + # VIEW TODO: Make #capture usable outside of ERB + # This dance is needed because Builder can't use capture + pos = output_buffer.length + yield + fragment = output_buffer.slice!(pos..-1) + controller.write_fragment(name, fragment, options) end end end |