Class: Kitchen::Directions::BakeAutotitledExercise::V1

Inherits:
Object
  • Object
show all
Defined in:
lib/kitchen/directions/bake_autotitled_exercise/v1.rb

Instance Method Summary collapse

Instance Method Details

#bake(exercise:, number:) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/kitchen/directions/bake_autotitled_exercise/v1.rb', line 5

def bake(exercise:, number:)
  exercise.add_class('unnumbered') unless number

  # bake problem
  exercise.problem.wrap_children('div', class: 'os-problem-container')
  exercise.problem.prepend(child:
    <<~HTML
      <h4 class="exercise-title" data-type="title">#{exercise.autogenerated_title}</h4>
    HTML
  )
  return unless exercise.solution

  # bake solution in place
  exercise.solution.wrap_children('div', class: 'os-solution-container')
  exercise.solution.prepend(child:
    <<~HTML
      <h4 class="solution-title" data-type="title">
        <span class="os-text">#{I18n.t(:"exercises.solution")}</span>
      </h4>
    HTML
  )
end