11{% comment %}
2- Display an episode's timings and learning objectives.
2+ Display episode's timings and learning objectives.
3+
4+ Regarding the `if page.*** == nil` below:
5+ all-in-one page combines all episodes into one.
6+ It, therefore, does not define its own objectives, exercises,
7+ and questions, which 'normal' episodes define in the front matter.
8+
9+ To display episodes' teaching and exercise times, as well as episode
10+ questions and objectives, we pass them as parameters to the Liquid's
11+ `include` statement when we generate the page:
12+
13+ {% include episode_overview.html teaching_time=e.teaching ... %}
14+
15+ Here we obtain the information we need either from the episode itself or
16+ from the parameters passed in.
317{% endcomment %}
18+
19+ {% if page.teaching == nil %}
20+ {% assign teaching_time = include.teaching_time %}
21+ {% else %}
22+ {% assign teaching_time = page.teaching %}
23+ {% endif %}
24+
25+ {% if page.exercises == nil %}
26+ {% assign exercise_time = include.exercise_time %}
27+ {% else %}
28+ {% assign exercise_time = page.exercises %}
29+ {% endif %}
30+
31+ {% if page.questions == nil %}
32+ {% assign episode_questions = include.episode_questions %}
33+ {% else %}
34+ {% assign episode_questions = page.questions %}
35+ {% endif %}
36+
37+ {% if page.objectives == nil %}
38+ {% assign episode_objectives = include.episode_objectives %}
39+ {% else %}
40+ {% assign episode_objectives = page.objectives %}
41+ {% endif %}
42+
43+
444< blockquote class ="objectives ">
545 < h2 > Overview</ h2 >
646
747 < div class ="row ">
848 < div class ="col-md-3 ">
9- < strong > Teaching:</ strong > {{ page.teaching }} min
49+ < strong > Teaching:</ strong > {{ teaching_time }} min
1050 < br />
11- < strong > Exercises:</ strong > {{ page.exercises }} min
51+ < strong > Exercises:</ strong > {{ exercise_time }} min
1252 </ div >
1353 < div class ="col-md-9 ">
1454 < strong > Questions</ strong >
1555 < ul >
16- {% for question in page.questions %}
56+ {% for question in episode_questions %}
1757 < li > {{ question|markdownify }}</ li >
1858 {% endfor %}
1959 </ ul >
@@ -26,7 +66,7 @@ <h2>Overview</h2>
2666 < div class ="col-md-9 ">
2767 < strong > Objectives</ strong >
2868 < ul >
29- {% for objective in page.objectives %}
69+ {% for objective in episode_objectives %}
3070 < li > {{ objective|markdownify }}</ li >
3171 {% endfor %}
3272 </ ul >
0 commit comments