[Experimental] enable internal caching of responsive_image_block tag results

This commit is contained in:
Joseph Wynn 2016-02-02 20:46:22 +00:00
parent ecdbbfd2b0
commit b77d0b83d0
1 changed files with 20 additions and 10 deletions

View File

@ -4,10 +4,15 @@ module Jekyll
include Jekyll::ResponsiveImage::Common
def render(context)
attributes = YAML.load(super)
cache_key = attributes.to_s
result = attributes['cache'] ? RenderCache.get(cache_key) : nil
if result.nil?
site = context.registers[:site]
config = make_config(site)
attributes = YAML.load(super)
image_template = attributes['template'] || config['template']
image = ImageProcessor.process(attributes['path'], config)
@ -17,7 +22,12 @@ module Jekyll
partial = File.read(image_template)
template = Liquid::Template.parse(partial)
template.render!(attributes.merge(site.site_payload))
result = template.render!(attributes.merge(site.site_payload))
RenderCache.set(cache_key, result)
end
result
end
end
end