Class: Kitchen::Directions::BakeExercisePrefixes::V1

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

Instance Method Summary collapse

Instance Method Details

#bake(chapter:, sections_prefixed:) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/kitchen/directions/bake_exercise_prefixes/v1.rb', line 5

def bake(chapter:, sections_prefixed:)
  sections_prefixed.each do |section_key|
    chapter.composite_pages.each do |composite_page|
      composite_page.search("section.#{section_key}").exercises.each do |exercise|
        problem = exercise.problem
        exercise_prefix =
          "<span class='os-text'>#{I18n.t(:"sections_prefixed.#{section_key}")}</span>"
        problem.prepend(child:
          <<~HTML
            #{exercise_prefix}
          HTML
        )
      end
    end
  end
end