aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view
diff options
context:
space:
mode:
authorCarlhuda <carlhuda@engineyard.com>2010-03-18 15:52:43 -0700
committerCarlhuda <carlhuda@engineyard.com>2010-03-18 15:52:43 -0700
commit71c9337f45f9c5461cbc6ddf6cab764ad0f82c3b (patch)
tree4e4a89ceca056d7ee4fcf329ecb56bbc0547d553 /actionpack/lib/action_view
parent523d0f3700f5bb68cdd3d549eaad63d8a88c2aef (diff)
downloadrails-71c9337f45f9c5461cbc6ddf6cab764ad0f82c3b.tar.gz
rails-71c9337f45f9c5461cbc6ddf6cab764ad0f82c3b.tar.bz2
rails-71c9337f45f9c5461cbc6ddf6cab764ad0f82c3b.zip
All tests pass without memoizing view_context
Diffstat (limited to 'actionpack/lib/action_view')
-rw-r--r--actionpack/lib/action_view/base.rb2
-rw-r--r--actionpack/lib/action_view/helpers/cache_helper.rb22
2 files changed, 21 insertions, 3 deletions
diff --git a/actionpack/lib/action_view/base.rb b/actionpack/lib/action_view/base.rb
index 859c5c0863..b82c6a8203 100644
--- a/actionpack/lib/action_view/base.rb
+++ b/actionpack/lib/action_view/base.rb
@@ -250,8 +250,6 @@ module ActionView #:nodoc:
else
klass = self
end
-
- klass.new(controller.lookup_context, {}, controller)
end
def initialize(lookup_context = nil, assigns_for_first_render = {}, controller = nil, formats = nil) #:nodoc:
diff --git a/actionpack/lib/action_view/helpers/cache_helper.rb b/actionpack/lib/action_view/helpers/cache_helper.rb
index f5c2127d3f..a904af56bb 100644
--- a/actionpack/lib/action_view/helpers/cache_helper.rb
+++ b/actionpack/lib/action_view/helpers/cache_helper.rb
@@ -32,9 +32,29 @@ module ActionView
# <i>Topics listed alphabetically</i>
# <% end %>
def cache(name = {}, options = nil, &block)
- safe_concat controller.fragment_for(name, options, &block)
+ safe_concat fragment_for(name, options, &block)
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
+ else
+ ret = yield
+ ActiveSupport::SafeBuffer.new(ret) if ret.is_a?(String)
+ end
+ end
end
end
end