Skip to content

Commit 5498b01

Browse files
committed
Add support for pages with HTML content
1 parent 9e1a3bc commit 5498b01

File tree

4 files changed

+13
-8
lines changed

4 files changed

+13
-8
lines changed

content/en/microbit.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
title: Python on the BBC micro:bit
2+
---
3+
4+
<h1>Coming soon!</h1>
5+
6+
<p>(In English)</p>

content/en/microbit.md

Lines changed: 0 additions & 6 deletions
This file was deleted.

pythonineducation/templates/pythonineducation/base.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,11 @@
6262
{% endblock %}
6363

6464
<main role="main" id="main">
65-
{{ content|markdown }}
65+
{% if content_format == 'md' %}
66+
{{ content|markdown }}
67+
{% else %}
68+
{{ content|safe }}
69+
{% endif %}
6670
</main>
6771
</div>
6872

pythonineducation/views.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@
66
def page_view(request, language='en', slug='home'):
77
page = get_object_or_404(Page, language=language, slug=slug)
88

9-
assert page.content_format == 'md', 'Markdown is only supported format'
9+
assert page.content_format in ['html', 'md'], 'Page content must use HTML or Markdown'
1010

1111
template = 'pythonineducation/page_{}.html'.format(language)
1212

1313
context = {
1414
'content': page.content,
15+
'content_format': page.content_format,
1516
'title': page.title,
1617
'language': language,
1718
}

0 commit comments

Comments
 (0)