class Kitchen::Directions::MoveCustomSectionToEocContainer::V1
Public Instance Methods
bake(chapter:, metadata_source:, container_key:, uuid_key:, section_selector:, append_to:, wrap_section:, wrap_content:, &block)
click to toggle source
# 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::EocCompositePageContainer.v1( container_key: container_key, uuid_key: uuid_key, metadata_source: metadata_source, content: content, append_to: append_to || chapter ) end