Class: Spirit::Render::Image

Inherits:
Template show all
Defined in:
lib/spirit/render/templates/image.rb

Overview

Renders a block image with a figure number.

Constant Summary collapse

IMAGE_TAG =

<img …>

'img'.freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(html) ⇒ Image

Creates a new image.



21
22
23
24
# File 'lib/spirit/render/templates/image.rb', line 21

def initialize(html)
  @html = html
  parse_or_raise
end

Class Method Details

.parse(text) ⇒ Object

Parses the given text for a block image.



16
17
18
# File 'lib/spirit/render/templates/image.rb', line 16

def self.parse(text)
  Image.new text
end

Instance Method Details

#render(locals = {}) ⇒ Object



26
27
28
# File 'lib/spirit/render/templates/image.rb', line 26

def render(locals={})
  super locals.merge(img: @html, caption: @node['alt'])
end