class JekyllIncludeCache::Tag

Public Instance Methods

render(context) click to toggle source
Calls superclass method
# File lib/jekyll-include-cache/tag.rb, line 7
def render(context)
  path   = path(context)
  params = parse_params(context) if @params
  return unless path

  key    = key(path, params)
  cached = JekyllIncludeCache.cache[key]

  if cached
    Jekyll.logger.debug "Include cache hit:", path
    cached
  else
    Jekyll.logger.debug "Include cache miss:", path
    JekyllIncludeCache.cache[key] = super
  end
end

Private Instance Methods

key(path, params) click to toggle source
# File lib/jekyll-include-cache/tag.rb, line 32
def key(path, params)
  Digest::MD5.hexdigest(path.to_s + params.to_s)
end
path(context) click to toggle source
# File lib/jekyll-include-cache/tag.rb, line 26
def path(context)
  site   = context.registers[:site]
  file   = render_variable(context) || @file
  locate_include_file(context, file, site.safe)
end