Eclectic Media Git archived_em.space_site / master utilities / renderer.py
master

Tree @master (Download .tar.gz)

renderer.py @masterraw · history · blame

import os

from pystache import Renderer
from jinja2 import Environment, FileSystemLoader
from markdown import markdown

renderer = Renderer(search_dirs='templates', file_extension='stache')


def render(path, context={}, **kwargs):
    file_loader = FileSystemLoader('templates')
    env = Environment(loader=file_loader)
    template = env.get_template(path)
    output = template.render(context, **kwargs)
    return output


def render_markdown(path):
    with open(path) as f:
        content = f.read()

    return markdown(content)