Example #1
0
def render_site(site):
    """Renders every content object in the site."""

    renderer = Renderer(site.settings)
    dest = site.settings["site"]
    os.makedirs(dest, exist_ok=True)

    for page in site.pages:
        print(page.name)
        out = os.path.join(dest, page.url)
        args = {"page": page, "site": site, "settings": site.settings}
        renderer.render(out, page.templates, args)

    for category in site.categories:
        print(category.name)
        out = os.path.join(dest, category.url)
        args = {
            "category": category,
            "site": site,
            "settings": site.settings,
        }
        renderer.render(out, category.templates, args)

        for item in category.items:
            print(item.value)
            out = os.path.join(dest, item.url)
            args = {"item": item, "site": site, "settings": site.settings}
            renderer.render(out, item.templates, args)
Example #2
0
def renderer(shared_datadir):
    settings = {"templates": f"{shared_datadir}/templates"}

    return Renderer(settings)