view piecrust/admin/views/__init__.py @ 816:d9b1e5ad869f

docs: Add space before link I always thought that adding a break line, it would automatically add a space. But from the current documentation page https://bolt80.com/piecrust/en/latest/getting-started/, looks like if the next line starts with a link, it gets truncated.
author Bruno P. Kinoshita <kinow@users.noreply.github.com>
date Sat, 22 Oct 2016 21:26:41 +1300
parents 5e91bc0e3b4d
children 2b0fa2e4c12f
line wrap: on
line source

from flask import render_template
from flask.views import View
from .menu import get_menu_context


class FoodTruckView(View):
    template_name = 'index.html'
    requires_menu = True

    def render_template(self, context):
        if self.requires_menu:
            context = with_menu_context()
        return render_template(self.template_name, **context)

    def get_context(self):
        return None

    def dispatch_request(self):
        ctx = self.get_context()
        return render_template(ctx)


def with_menu_context(context=None):
    if context is None:
        context = {}
    context['menu'] = get_menu_context()
    return context