Example #1
0
def morias_template(req, template, **kwargs):
    if 'lang' not in kwargs:                # lang could be set explicit
        kwargs['lang'] = get_lang(req)
        languages = get_langs(req)
    else:
        languages = (kwargs['lang'],)       # then use languages

    kwargs['debug'] = req.cfg.debug

    if hasattr(req, 'login'):
        kwargs['login'] = req.login

    kwargs['site'] = Object()
    kwargs['site'].name = req.cfg.site_name
    kwargs['site'].description = req.cfg.site_description
    kwargs['site'].keywords = req.cfg.site_keywords
    kwargs['site'].author = req.cfg.site_author
    kwargs['site'].copyright = req.cfg.site_copyright
    kwargs['site'].styles = req.cfg.site_styles + kwargs.pop('styles', ())
    kwargs['site'].this = req.uri
    kwargs['site'].scheme = req.scheme
    kwargs['site'].domain = req.hostname

    kwargs['site'].modules = req.cfg.modules
    kwargs['site'].footers = req.cfg.footers

    kwargs['e'] = sdict()

    translations = translation('morias',
                               localedir=req.cfg.locales,
                               languages=languages,
                               fallback=True)

    return jinja_template(template, req.cfg.templates, translations, **kwargs)