Class: Metanorma::Html::Drops::ExampleDrop

Inherits:
BlockElementDrop show all
Defined in:
lib/metanorma/html/drops/example_drop.rb

Instance Attribute Summary

Attributes inherited from BlockElementDrop

#content_html, #css_class, #id, #label_html, #type

Class Method Summary collapse

Methods inherited from BlockElementDrop

#initialize

Constructor Details

This class inherits a constructor from Metanorma::Html::Drops::BlockElementDrop

Class Method Details

.from_model(example, renderer:) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/metanorma/html/drops/example_drop.rb', line 7

def self.from_model(example, renderer:)
  id = renderer.safe_attr(example, :id)
  label = renderer.extract_block_label(example, "EXAMPLE")

  content_html = renderer.capture_output do
    renderer.render_block_children(example,
                                   children: BaseRenderer::BLOCK_CHILDREN)
  end

  new(
    id: id,
    label_html: renderer.escape_html(label),
    content_html: content_html,
    css_class: "example",
  )
end