Class: Jekyll::Img

Inherits:
JekyllSupport::JekyllTag
  • Object
show all
Includes:
JekyllImgVersion
Defined in:
lib/jekyll_img.rb

Overview

Plugin implementation

Constant Summary

Constants included from JekyllImgVersion

JekyllImgVersion::VERSION

Instance Method Summary collapse

Instance Method Details

#render_implObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/jekyll_img.rb', line 23

def render_impl
  @helper.gem_file __FILE__ # This enables plugin attribution

  @die_on_img_error = @tag_config['die_on_img_error'] == true if @tag_config
  @pry_on_img_error = @tag_config['pry_on_img_error'] == true if @tag_config

  props = ImgProperties.new
  props.attribute         = @helper.attribute
  props.attribution       = @helper.attribution
  props.align             = @helper.parameter_specified?('align') || 'inline'
  props.alt               = @helper.parameter_specified? 'alt'
  props.caption           = @helper.parameter_specified? 'caption'
  props.classes           = @helper.parameter_specified? 'class'
  props.die_on_img_error  = @die_on_img_error
  props.id                = @helper.parameter_specified? 'id'
  props.nofollow          = @helper.parameter_specified? 'nofollow'
  props.size              = @helper.parameter_specified?('size') || @helper.parameter_specified?('_size')
  props.src               = @helper.parameter_specified? 'src'
  props.style             = @helper.parameter_specified? 'style'
  props.target            = @helper.parameter_specified? 'target'
  props.title             = @helper.parameter_specified? 'title'
  props.url               = @helper.parameter_specified? 'url'
  props.wrapper_class     = @helper.parameter_specified? 'wrapper_class'
  props.wrapper_style     = @helper.parameter_specified? 'wrapper_style'

  @builder = ImgBuilder.new(props)
  @builder.to_s
rescue ImgError => e # jekyll_plugin_support handles StandardError
  @logger.error { e.logger_message }
  binding.pry if @pry_on_img_error # rubocop:disable Lint/Debugger
  exit! 1 if @die_on_img_error

  e.html_message
end