diff options
author | Andrew Rove <rovermicrover@mac.com> | 2013-06-01 15:45:43 -0500 |
---|---|---|
committer | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2013-06-25 20:46:02 -0300 |
commit | f341acdae3abfa97247736dde01f5e79c61de7d2 (patch) | |
tree | 76158e2bed0f4011e4dd2e1a4370e31c4be2f012 /actionview/lib/action_view/helpers | |
parent | 840c552047a660d0a66883fb9c0cb144d5e728fb (diff) | |
download | rails-f341acdae3abfa97247736dde01f5e79c61de7d2.tar.gz rails-f341acdae3abfa97247736dde01f5e79c61de7d2.tar.bz2 rails-f341acdae3abfa97247736dde01f5e79c61de7d2.zip |
Move the write portion of fragment_for to its own method to allow for easier creation of custom cache methods.
Diffstat (limited to 'actionview/lib/action_view/helpers')
-rw-r--r-- | actionview/lib/action_view/helpers/cache_helper.rb | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/actionview/lib/action_view/helpers/cache_helper.rb b/actionview/lib/action_view/helpers/cache_helper.rb index 8fc78ea7fb..2f2c8544ee 100644 --- a/actionview/lib/action_view/helpers/cache_helper.rb +++ b/actionview/lib/action_view/helpers/cache_helper.rb @@ -179,17 +179,21 @@ module ActionView if fragment = controller.read_fragment(name, options) fragment else - # VIEW TODO: Make #capture usable outside of ERB - # This dance is needed because Builder can't use capture - pos = output_buffer.length - yield - output_safe = output_buffer.html_safe? - fragment = output_buffer.slice!(pos..-1) - if output_safe - self.output_buffer = output_buffer.class.new(output_buffer) - end - controller.write_fragment(name, fragment, options) + write_fragment_for(name, options, &block) + end + end + + def write_fragment_for(name = {}, options = nil, &block) #:nodoc: + # VIEW TODO: Make #capture usable outside of ERB + # This dance is needed because Builder can't use capture + pos = output_buffer.length + yield + output_safe = output_buffer.html_safe? + fragment = output_buffer.slice!(pos..-1) + if output_safe + self.output_buffer = output_buffer.class.new(output_buffer) end + controller.write_fragment(name, fragment, options) end end end |