Sha256: 2ba4521efb4d300c12ef8b1e31b038032715d3a5877a949edfcce666426410ca
Contents?: true
Size: 1.58 KB
Versions: 2
Compression:
Stored size: 1.58 KB
Contents
# frozen_string_literal: true module Kitchen::Directions::BakeChapterReviewExercises # Main difference from v1 is the presence of a section title # and some additional wrappers class V2 renderable def bake(chapter:, metadata_source:, append_to:, klass:) @klass = klass @metadata = metadata_source.children_to_keep.copy @title = I18n.t(:"eoc.#{klass}") exercise_clipboard = Kitchen::Clipboard.new chapter.non_introduction_pages.each do |page| sections = page.search("section.#{@klass}") sections.each do |exercise_section| exercise_section.first("[data-type='title']")&.trash # Get parent page title section_title = Kitchen::Directions::EocSectionTitleLinkSnippet.v1(page: page) exercise_section.exercises.each do |exercise| exercise.document.pantry(name: :link_text).store( "#{I18n.t(:exercise_label)} #{chapter.count_in(:book)}.#{exercise.count_in(:chapter)}", label: exercise.id ) end # Configure section title & wrappers exercise_section.prepend(child: section_title) exercise_section.wrap('<div class="os-section-area">') exercise_section = exercise_section.parent exercise_section.cut(to: exercise_clipboard) end end return if exercise_clipboard.none? @content = <<~HTML <div class="os-#{@klass}"> #{exercise_clipboard.paste} </div> HTML append_to.append(child: render(file: 'review_exercises.xhtml.erb')) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
openstax_kitchen-3.2.0 | lib/kitchen/directions/bake_chapter_review_exercises/v2.rb |
openstax_kitchen-3.1.0 | lib/kitchen/directions/bake_chapter_review_exercises/v2.rb |