diff options
-rw-r--r-- | theme/templates/page.html | 84 |
1 files changed, 38 insertions, 46 deletions
diff --git a/theme/templates/page.html b/theme/templates/page.html index 1467e68..51c5ea1 100644 --- a/theme/templates/page.html +++ b/theme/templates/page.html @@ -7,6 +7,29 @@ <link rel="stylesheet" href="{{ staticBase }}/print.css"> {% endblock %} + +{% macro articleContent(content) %} + {% for section in content %} + {% if section.type == "normal" %} + {% autoescape false %}{{ section.content }}{% endautoescape %} + {% elif section.type == "exercise" %} + <div class="exercise"> + <div class="exercise-header">Exercise #{{ exercise }}</div> + {% autoescape false %}{{ section.content }}{% endautoescape %} + <pre><code>{% autoescape false %}{{ section.code.base|code }}{% endautoescape %}</code></pre> + {% set exercise = exercise + 1 %} + </div> + {% elif section.type == "quiz" %} + <div class="quiz"> + <div class="exercise-header">Exercise #{{ exercise }}</div> + {% autoescape false %}{{ section.content }}{% endautoescape %} + {% autoescape false %}{{ section.quiz.base }}{% endautoescape %} + {% set exercise = exercise + 1 %} + </div> + {% endif %} + {% endfor %} +{% endmacro %} + {% set exercise = 1 %} {% block content %} {# Cover #} @@ -45,61 +68,30 @@ {# Pages content #} <section> <article id="README.md"> - {% for section in pages["README.md"].content %} - {% if section.type == "normal" %} - {% autoescape false %}{{ section.content }}{% endautoescape %} - {% elif section.type == "exercise" %} - <div class="exercise"> - <div class="exercise-header">Exercise #{{ exercise }}</div> - {% autoescape false %}{{ section.content }}{% endautoescape %} - <pre><code>{% autoescape false %}{{ section.code.base|code }}{% endautoescape %}</code></pre> - {% set exercise = exercise + 1 %} - </div> - {% elif section.type == "quiz" %} - <div class="quiz"> - <div class="exercise-header">Exercise #{{ exercise }}</div> - {% autoescape false %}{{ section.content }}{% endautoescape %} - {% autoescape false %}{{ section.quiz.base }}{% endautoescape %} - {% set exercise = exercise + 1 %} - </div> - {% endif %} - {% endfor %} + {{ articleContent(pages["README.md"].content) }} </article> </section> {% for item in summary.chapters %} - {% if item.articles.length > 0 %} <section> <article id="{{ item.path }}" class="new-chapter"> <h1>{{ item.title }}</h1> </article> - {% for article in item.articles %} - {% if pages[article.path] %} - <article id="{{ article.path }}"> - {% for section in pages[article.path].content %} - {% if section.type == "normal" %} - {% autoescape false %}{{ section.content }}{% endautoescape %} - {% elif section.type == "exercise" %} - <div class="exercise"> - <div class="exercise-header">Exercise #{{ exercise }}</div> - {% autoescape false %}{{ section.content }}{% endautoescape %} - <pre><code>{% autoescape false %}{{ section.code.base|code }}{% endautoescape %}</code></pre> - {% set exercise = exercise + 1 %} - </div> - {% elif section.type == "quiz" %} - <div class="quiz"> - <div class="exercise-header">Exercise #{{ exercise }}</div> - {% autoescape false %}{{ section.content }}{% endautoescape %} - {% autoescape false %}{{ section.quiz.base }}{% endautoescape %} - {% set exercise = exercise + 1 %} - </div> - {% endif %} - {% endfor %} - </article> - {% endif %} - {% endfor %} + <article> + {{ articleContent(pages[item.path].content) }} + </article> + + {% if item.articles.length > 0 %} + {% for article in item.articles %} + {% if pages[article.path] %} + <article id="{{ article.path }}"> + {{ articleContent(pages[article.path].content) }} + </article> + {% endif %} + {% endfor %} + {% endif %} </section> - {% endif %} + { {% endfor %} |