Class: Jekyll::Engine::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/jekyll/rendering.rb

Direct Known Subclasses

Erb, Liquid

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(payload, content = nil, info = {}, data = {}) ⇒ Base

Returns a new instance of Base.



109
110
111
# File 'lib/jekyll/rendering.rb', line 109

def initialize(payload, content = nil, info = {}, data = {})
  @payload, @content, @info, @data = payload, content, info, data
end

Instance Attribute Details

#contentObject

Returns the value of attribute content.



107
108
109
# File 'lib/jekyll/rendering.rb', line 107

def content
  @content
end

#dataObject (readonly)

Returns the value of attribute data.



106
107
108
# File 'lib/jekyll/rendering.rb', line 106

def data
  @data
end

#infoObject (readonly)

Returns the value of attribute info.



106
107
108
# File 'lib/jekyll/rendering.rb', line 106

def info
  @info
end

#payloadObject (readonly)

Returns the value of attribute payload.



106
107
108
# File 'lib/jekyll/rendering.rb', line 106

def payload
  @payload
end

Class Method Details

.render(payload, content, info, data = {}, layout = nil) ⇒ Object

call-seq:

Engine::Base.render(*args)

Renders the output. Defers to engine’s render method.



102
103
104
# File 'lib/jekyll/rendering.rb', line 102

def self.render(payload, content, info, data = {}, layout = nil)
  new(payload, content, info, data).render(layout || content)
end

Instance Method Details

#renderObject

call-seq:

render

Renders the output. Must be implemented by subclass.

Raises:

  • (NotImplementedError)


117
118
119
# File 'lib/jekyll/rendering.rb', line 117

def render
  raise NotImplementedError
end

#render_error(err, renderer = nil, trace = Rendering::ERROR_TRACE) ⇒ Object



121
122
123
124
125
126
127
128
129
130
131
# File 'lib/jekyll/rendering.rb', line 121

def render_error(err, renderer = nil, trace = Rendering::ERROR_TRACE)
  msg = [self.class.name.split('::').last]
  msg << "[#{renderer}]" if renderer

  msg << 'Exception:' << err
  msg << "(in #{data['layout'] || '(top)'})"

  msg << "(from #{err.backtrace[0, trace].join(', ')})" if trace > 0

  msg.join(' ')
end