From 5d27282363a38a8f8548f8dafbb842bdc393846b Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Sun, 23 May 2010 13:22:56 -0300 Subject: [PATCH] fragment_for backport from master [#4673 state:committed] --- .../lib/action_controller/caching/fragments.rb | 11 +++++++---- 1 files changed, 7 insertions(+), 4 deletions(-) diff --git a/actionpack/lib/action_controller/caching/fragments.rb b/actionpack/lib/action_controller/caching/fragments.rb index eefb649..904d785 100644 --- a/actionpack/lib/action_controller/caching/fragments.rb +++ b/actionpack/lib/action_controller/caching/fragments.rb @@ -36,15 +36,18 @@ module ActionController #:nodoc: def fragment_for(buffer, name = {}, options = nil, &block) #:nodoc: if perform_caching - if cache = read_fragment(name, options) - buffer.safe_concat(cache.html_safe) + if fragment_exist?(name, options) + if cache = read_fragment(name, options) + buffer.safe_concat(cache.html_safe) + end else pos = buffer.length - block.call + yield write_fragment(name, buffer[pos..-1], options) end else - block.call + ret = yield + ret.html_safe if ret.is_a?(String) end end -- 1.7.1