forked from unit/ciclostile
Support multiple templates
This commit is contained in:
parent
2a2daaa42d
commit
8f558ce0b8
|
@ -3,7 +3,7 @@ import os
|
|||
import markdown
|
||||
import jinja2
|
||||
|
||||
template_file = 'template.html'
|
||||
template_path = 'templates'
|
||||
md_path = './markdown'
|
||||
html_path = './target'
|
||||
|
||||
|
@ -15,6 +15,9 @@ def write_page(page, out_name):
|
|||
|
||||
|
||||
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:
|
||||
template = f.read()
|
||||
|
||||
|
|
8
example/markdown/test_other_template.md
Normal file
8
example/markdown/test_other_template.md
Normal file
|
@ -0,0 +1,8 @@
|
|||
Title: Other Test Page
|
||||
Template: other_template
|
||||
|
||||
|
||||
# Title
|
||||
|
||||
Some other text
|
||||
|
11
example/templates/other_template.html
Normal file
11
example/templates/other_template.html
Normal file
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>{{ title }}</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>Other Template</h1>
|
||||
{{ content }}
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user