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
<<~HTML
<div class="os-#{container_key}">
#{section_clipboard.paste}
</div>
HTML
else
section_clipboard.paste
end
Kitchen::Directions::CompositePageContainer.v1(
container_key: container_key,
uuid_key: uuid_key,
metadata_source: metadata_source,
content: content,
append_to: append_to || chapter
)
end
|