Module: ActionView::Helpers::CacheHelper

Defined in:
lib/extended_fragment_cache.rb

Overview

See ActionController::Caching::Fragments for usage instructions.

Instance Method Summary collapse

Instance Method Details

#cache(name = {}, options = nil, interpolation = {}, &block) ⇒ Object



134
135
136
137
138
139
140
141
142
143
144
145
# File 'lib/extended_fragment_cache.rb', line 134

def cache(name = {}, options=nil, interpolation = {}, &block)
  begin
    content = @controller.cache_erb_fragment(block, name, options, interpolation) || ""
  rescue
    content = ""
  rescue MemCache::MemCacheError => err
    content = ""
  end

  interpolation.keys.each{|k| content.sub!(k.to_s, interpolation[k].to_s)}
  content
end