Class: Jekyll::ResponsiveImage::Block
- Inherits:
-
Liquid::Block
- Object
- Liquid::Block
- Jekyll::ResponsiveImage::Block
- Includes:
- Common
- Defined in:
- lib/jekyll/responsive_image/block.rb
Instance Method Summary collapse
Methods included from Common
Methods included from Utils
#format_output_path, #image_hash, #relative_dirname, #symbolize_keys
Instance Method Details
#render(context) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/jekyll/responsive_image/block.rb', line 6 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) image_template = attributes['template'] || config['template'] image = ImageProcessor.process(attributes['path'], config) attributes['original'] = image[:original] attributes['resized'] = image[:resized] partial = File.read(image_template) template = Liquid::Template.parse(partial) result = template.render!(attributes.merge(site.site_payload)) RenderCache.set(cache_key, result) end result end |