Module: Kitchen::Directions::BakeAutotitledNotes

Defined in:
lib/kitchen/directions/bake_notes/bake_autotitled_notes.rb

Class Method Summary collapse

Class Method Details

.bake_note(note:, options: {}) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/kitchen/directions/bake_notes/bake_autotitled_notes.rb', line 25

def self.bake_note(note:, options: {})
  note.wrap_children(class: 'os-note-body')

  if options[:bake_subtitle]
    BakeNoteSubtitle.v1(note: note, cases: options[: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 options[:bake_exercises]
end

.v1(book:, classes:, options: { bake_subtitle: true, cases: false, bake_exercises: false }) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/kitchen/directions/bake_notes/bake_autotitled_notes.rb', line 6

def self.v1(book:, classes:, options: {
  bake_subtitle: true,
  cases: false,
  bake_exercises: false
})
  options.reverse_merge!(
    bake_subtitle: true,
    cases: false,
    bake_exercises: false
  )

  book.notes.each do |note|
    next unless (note.classes & classes).any?

    bake_note(
      note: note, options: options)
  end
end