all repos — py-vite @ 8f71e8e669389da6bf38260b63550096372c0f87

the original vite, written in python

feat(make.py): markdown to jinja to output
icyphox icyph0x@protonmail.com
Sat, 17 Mar 2018 02:28:27 +0530
commit

8f71e8e669389da6bf38260b63550096372c0f87

parent

83c00b04d32e91cd0c5f6c488743c4131bb5281f

1 files changed, 15 insertions(+), 2 deletions(-)

jump to
M make.pymake.py

@@ -9,9 +9,22 @@ BUILD_PATH = 'build/'

TEMPL_PATH = 'templates/' # jinja2 -def jinja_render(markdown_text, template_file): +def jinja_render(html_text, template_file): template_loader = jinja2.FileSystemLoader(searchpath=TEMPL_PATH) env = jinja2.Environment(loader=template_loader) template = env.get_template(template_file) - output = template.render(body=markdown_text) + output = template.render(body=html_text) return output + +def markdown_render(filename): + html_text = markdown_path(PAGES_PATH + filename) + return html_text + +def main(): + template_file = TEMPL_PATH + 'template.html' + for page in os.listdir(PAGES_PATH): + html_text = markdown_render(page) + output = jinja_render(html_text, template_file) + with open(BUILD_PATH + html_text, 'w') as f: + f.write(output) + print('Rendered %s' % (page))