Class: Kitchen::Directions::MoveCustomSectionToEocContainer::V1

Inherits:
Object
  • Object
show all
Defined in:
lib/kitchen/directions/move_custom_section_to_eoc_container/v1.rb

Instance Method Summary collapse

Instance Method Details

#bake(chapter:, metadata_source:, container_key:, uuid_key:, section_selector:, append_to:, wrap_section:, wrap_content:, &block) ⇒ Object



7
8
9
10
11
12
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
# File 'lib/kitchen/directions/move_custom_section_to_eoc_container/v1.rb', line 7

def bake(chapter:, metadata_source:, container_key:, uuid_key:,
         section_selector:, append_to:, wrap_section:, wrap_content:,
         &block)
  section_clipboard = Kitchen::Clipboard.new
  pages = chapter.pages
  sections = pages.search(section_selector)
  sections.each(&block)
  if wrap_section
    sections.each { |section| section.wrap('<div class="os-section-area">') }
    sections = pages.search('div.os-section-area')
  end
  sections.cut(to: section_clipboard)

  return if section_clipboard.none?

  content = \
    if wrap_content
      "        <div class=\"os-\#{container_key}\">\n          \#{section_clipboard.paste}\n        </div>\n      HTML\n    else\n      section_clipboard.paste\n    end\n\n  Kitchen::Directions::CompositePageContainer.v1(\n    container_key: container_key,\n    uuid_key: uuid_key,\n    metadata_source: metadata_source,\n    content: content,\n    append_to: append_to || chapter\n  )\nend\n"