Class: Middleman::FileRenderer

Inherits:
Object
  • Object
show all
Defined in:
lib/middleman-mdocs/file_renderer_cache.rb

Constant Summary collapse

ORIGINAL_RENDER =
Engine.fetch_from(self).decorated_methods_for(:instance_methods, :render)[0].method.instance_variable_get('@method')

Instance Method Summary collapse

Instance Method Details

#render(locs, opts, context, &block) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/middleman-mdocs/file_renderer_cache.rb', line 9

def render(locs, opts, context, &block)
  return ORIGINAL_RENDER.bind(self).call(locs, opts, context, &block) # if locs[:rack]

  cache_key = Digest::MD5.hexdigest("#{locs.to_h.to_json}_#{opts.to_h.to_json}")
  
  ::MiddlemanMdocs::Extension.cache.fetch([cache_key, 'file_render']) do
    ORIGINAL_RENDER.bind(self).call(locs, opts, context, &block)
  end
end