Zionetrix::Git
Repositories
Help
Report an Issue
MyCoServer
Code
Commits
Branches
Tags
Search
Tree:
7004713
Branches
Tags
master
MyCoServer
mycoserver
templates
__init__.py
Initial commit
Benjamin Renard
commited
7004713
at 2014-01-12 00:33:07
__init__.py
Blame
History
Raw
# -*- coding: utf-8 -*- """Mako templates rendering""" import json import mako.lookup import os from . import helpers js = lambda x: json.dumps(x, encoding='utf-8', ensure_ascii=False) def load_templates(ctx): # Create the Mako TemplateLookup, with the default auto-escaping. return mako.lookup.TemplateLookup( default_filters=['h'], directories=[os.path.join(ctx.conf['app_dir'], 'templates')], input_encoding='utf-8', module_directory=os.path.join(ctx.conf['cache_dir'], 'templates'), ) def render(ctx, template_path, **kw): return ctx.templates.get_template(template_path).render_unicode( ctx=ctx, helpers=helpers, js=js, N_=lambda message: message, req=ctx.req, **kw).strip() def render_def(ctx, template_path, def_name, **kw): return ctx.templates.get_template(template_path).get_def(def_name).render_unicode( _=ctx.translator.ugettext, ctx=ctx, js=js, N_=lambda message: message, req=ctx.req, **kw).strip()