Render cover

This commit is contained in:
Jake Howard 2017-03-28 21:31:42 +01:00
parent 6075d540d8
commit ca8b97bdb0
2 changed files with 13 additions and 4 deletions

View file

@ -1,6 +1,7 @@
import click
from md_pdf.build.md import read_files
from md_pdf.build.pandoc import build_document
from md_pdf.build.cover import render_cover
@click.command('build', short_help="Build document")
@ -10,5 +11,6 @@ from md_pdf.build.pandoc import build_document
def cli(in_files, bibliography, output):
data = read_files(in_files)
doc = build_document(data, bibliography)
print(doc)
render_cover()

View file

@ -1,9 +1,16 @@
from jinja2 import Template
from md_pdf.utils import PROJECT_DIR
import os
def render_cover(context):
with open("cover-template.html") as f:
COVER_TEMPLATE = os.path.join(PROJECT_DIR, 'assets', 'cover-template.html')
OUTPUT_COVER_FILE = os.path.join(PROJECT_DIR, 'assets', 'cover.html')
def render_cover(context={}):
with open(COVER_TEMPLATE) as f:
template = Template(f.read())
with open("cover.html", "w") as f:
with open(OUTPUT_COVER_FILE, "w") as f:
cover = template.render(context)
f.write(cover)
return cover