Class: Kitchen::Directions::BakeAutotitledExercise::V3
- Defined in:
- lib/kitchen/directions/bake_autotitled_exercise/v3.rb
Overview
Differences from V2:
-
Exercise with solution has class os-hasSolution
-
Solution id is based on exercise id
Instance Method Summary collapse
Instance Method Details
#bake(exercise:, title:) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/kitchen/directions/bake_autotitled_exercise/v3.rb', line 8 def bake(exercise:, title:) exercise.add_class('unnumbered') exercise.titles.first&.trash # bake problem exercise.prepend(child: <<~HTML <h3 class="os-title" data-type="title"> <span class="os-title-label">#{title}</span> </h3> HTML ) exercise.problem.wrap_children(class: 'os-problem-container') return unless exercise.solution exercise.add_class('os-hasSolution') exercise.solution.id = "#{exercise.id}-solution" exercise.solution.wrap_children(class: 'os-solution-container') exercise.solution.prepend(child: <<~HTML <h4 class="solution-title" data-type="title"> <span class="os-text">#{I18n.t(:solution)}</span> </h4> HTML ) end |