Module: Jekyll::DistorteD::Molecule::SVG

Includes:
Cooltrainer::DistorteD::SVG
Defined in:
lib/distorted-jekyll/molecule/svg.rb

Instance Method Summary collapse

Instance Method Details

#render_to_output_buffer(context, output) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/distorted-jekyll/molecule/svg.rb', line 13

def render_to_output_buffer(context, output)
  super
  begin
    # Liquid doesn't seem able to reference symbolic keys,
    # so convert everything to string for template.
    # Not stripping :full tags like Image because all of our
    # SVG variations will be full-res for now.
    filez = files.map{ |f|
      f.transform_values(&:to_s).transform_keys(&:to_s)
    }
    output << parse_template.render({
      'name' => @name,
      'path' => @relative_dest,
      'alt' => abstract(:alt),
      'title' => abstract(:title),
      'href' => abstract(:href),
      'caption' => abstract(:caption),
      'loading' => abstract(:loading),
      'sources' => filez,
      'fallback_img' => @name,
    })
  rescue Liquid::SyntaxError => l
    unless Jekyll.env == 'production'.freeze
      output << parse_template(name: 'error_code'.freeze).render({
        'message' => l.message,
      })
    end
  end
  output
end