Sha256: ff01cdd69d4b2f47997e2ade13b1963115ac55f01f3a7b03eb2154a8f6ef7ccc

Contents?: true

Size: 1.03 KB

Versions: 7

Compression:

Stored size: 1.03 KB

Contents

# frozen_string_literal: true

module Kitchen
  module Directions
    module BakeAutotitledNotes
      def self.v1(book:, classes:, bake_subtitle: true, cases: false, bake_exercises: false)
        book.notes.each do |note|
          next unless (note.classes & classes).any?

          bake_note(
            note: note, bake_subtitle: bake_subtitle, cases: cases, bake_exercises: bake_exercises)
        end
      end

      def self.bake_note(note:, bake_subtitle:, cases:, bake_exercises:)
        Kitchen::Directions::BakeIframes.v1(outer_element: note)
        note.wrap_children(class: 'os-note-body')

        if bake_subtitle
          BakeNoteSubtitle.v1(note: note, cases: cases)
        else
          note.title&.trash
        end

        note.prepend(child:
          <<~HTML
            <h3 class="os-title" data-type="title">
              <span class="os-title-label">#{note.autogenerated_title}</span>
            </h3>
          HTML
        )

        BakeNoteExercise.v2(note: note) if bake_exercises
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
openstax_kitchen-19.0.0 lib/kitchen/directions/bake_notes/bake_autotitled_notes.rb
openstax_kitchen-18.0.0 lib/kitchen/directions/bake_notes/bake_autotitled_notes.rb
openstax_kitchen-17.1.0 lib/kitchen/directions/bake_notes/bake_autotitled_notes.rb
openstax_kitchen-17.0.0 lib/kitchen/directions/bake_notes/bake_autotitled_notes.rb
openstax_kitchen-16.0.0 lib/kitchen/directions/bake_notes/bake_autotitled_notes.rb
openstax_kitchen-15.0.0 lib/kitchen/directions/bake_notes/bake_autotitled_notes.rb
openstax_kitchen-14.0.0 lib/kitchen/directions/bake_notes/bake_autotitled_notes.rb