Support multiple templates

This commit is contained in:
uid 2017-11-17 15:08:02 +01:00
parent 2a2daaa42d
commit 8f558ce0b8
4 changed files with 23 additions and 1 deletions

View File

@ -3,7 +3,7 @@ import os
import markdown import markdown
import jinja2 import jinja2
template_file = 'template.html' template_path = 'templates'
md_path = './markdown' md_path = './markdown'
html_path = './target' html_path = './target'
@ -15,6 +15,9 @@ def write_page(page, out_name):
def render_page(data): def render_page(data):
template_name = data.get('template', 'default')
template_file = os.path.join(template_path, template_name + '.html')
with open(template_file) as f: with open(template_file) as f:
template = f.read() template = f.read()

View File

@ -0,0 +1,8 @@
Title: Other Test Page
Template: other_template
# Title
Some other text

View File

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<title>{{ title }}</title>
</head>
<body>
<h1>Other Template</h1>
{{ content }}
</body>
</html>