[Experimental] enable internal caching of responsive_image_block tag results
This commit is contained in:
parent
1565091d6e
commit
c9b9c97faf
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue